11name : Build and Push to GHCR
22
33on :
4- push :
5- branches :
6- - main
7- - develop
4+ workflow_run :
5+ workflows : ["Run Tests"]
6+ types :
7+ - completed
8+ branches : [ main, develop ]
9+
810
911jobs :
1012 build-push :
1113 runs-on : ubuntu-latest
12-
14+ if : ${{ github.event.workflow_run.conclusion == 'success' }}
15+
1316 steps :
14- - name : Checkout code
15- uses : actions/checkout@v3
16-
17- - name : Login to GitHub Container Registry
18- uses : docker/login-action@v2
19- with :
20- registry : ghcr.io
21- username : ${{ github.actor }}
22- password : ${{ secrets.GITHUB_TOKEN }}
23-
24- - name : Build and push Docker image
25- uses : docker/build-push-action@v4
26- with :
27- context : .
28- file : memory-infra/docker/Dockerfile
29- push : true
30- tags : |
31- ghcr.io/${{ github.repository }}/memory-app:${{ github.sha }}
32- ${{ github.ref == 'refs/heads/main' && format('ghcr.io/{0}/memory-app:latest', github.repository) || format('ghcr.io/{0}/memory-app:dev', github.repository) }}
17+ - name : Checkout code
18+ uses : actions/checkout@v3
19+
20+ - name : Login to GitHub Container Registry
21+ uses : docker/login-action@v2
22+ with :
23+ registry : ghcr.io
24+ username : ${{ github.actor }}
25+ password : ${{ secrets.GITHUB_TOKEN }}
26+
27+ - name : Convert to lowercase
28+ id : string
29+ uses : ASzc/change-string-case-action@v5
30+ with :
31+ string : ${{ github.repository }}
32+
33+ - name : Build and push Docker image
34+ uses : docker/build-push-action@v4
35+ with :
36+ context : .
37+ file : memory-infra/docker/Dockerfile
38+ push : true
39+ tags : |
40+ ghcr.io/${{ steps.string.outputs.lowercase }}/memory-app:${{ github.sha }}
41+ ${{ github.ref == 'refs/heads/main' && format('ghcr.io/{0}/memory-app:latest', steps.string.outputs.lowercase) || format('ghcr.io/{0}/memory-app:dev', steps.string.outputs.lowercase) }}
0 commit comments