@@ -2,26 +2,47 @@ name: Build and Push
22
33on :
44 push :
5- branches : [dev, main, feat/**]
5+ branches : [main, dev, 'feat/**', 'fix/**', 'refactor/**', 'chore/**']
6+ pull_request :
7+ branches : [main, dev]
8+ workflow_dispatch :
9+ inputs :
10+ force_push :
11+ description : ' Force push image to registry?'
12+ type : boolean
13+ default : false
14+
15+ concurrency :
16+ group : ${{ github.workflow }}-${{ github.ref }}
17+ cancel-in-progress : true
618
719env :
20+ FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 : true
821 REGISTRY : ghcr.io
922 IMAGE_NAME : ${{ github.repository }}
1023
1124jobs :
1225 build-push :
1326 runs-on : ubuntu-latest
27+ env :
28+ IS_BASE_BRANCH : ${{ github.ref_name == 'main' || github.ref_name == 'dev' }}
29+ IS_PUSH : ${{ github.event_name == 'push' }}
30+ FORCE_PUSH : ${{ github.event.inputs.force_push == 'true' }}
31+
1432 permissions :
1533 contents : read
1634 packages : write
1735
1836 steps :
19- - uses : actions/checkout@v4
37+ - name : Checkout repository
38+ uses : actions/checkout@v4
2039
2140 - name : Set up Docker Buildx
2241 uses : docker/setup-buildx-action@v3
2342
2443 - name : Log in to the Container registry
44+ if : ${{ (env.IS_PUSH == 'true' && env.IS_BASE_BRANCH == 'true') ||
45+ env.FORCE_PUSH == 'true' }}
2546 uses : docker/login-action@v3
2647 with :
2748 registry : ${{ env.REGISTRY }}
@@ -36,14 +57,16 @@ jobs:
3657 tags : |
3758 type=ref,event=branch
3859 type=sha,format=short
39- type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
60+ # latest вешаем только когда мерджим в main
61+ type=raw,value=latest,enable=${{ github.ref_name == 'main' }}
4062
4163 - name : Build and push Docker image
4264 uses : docker/build-push-action@v5
4365 with :
4466 context : .
4567 file : ./Dockerfile.prod
46- push : true
68+ push : ${{ (env.IS_PUSH == 'true' && env.IS_BASE_BRANCH == 'true') ||
69+ env.FORCE_PUSH == 'true' }}
4770 tags : ${{ steps.meta.outputs.tags }}
4871 labels : ${{ steps.meta.outputs.labels }}
4972 cache-from : type=gha
0 commit comments