File tree Expand file tree Collapse file tree 1 file changed +48
-1
lines changed Expand file tree Collapse file tree 1 file changed +48
-1
lines changed Original file line number Diff line number Diff line change 1- name : Build and Push Docker Image
21
32on :
43 push :
5352 *.labels=${{ steps.meta.outputs.labels }}
5453 push : true
5554
55+ name : Build and Push Docker Image
56+
57+ on :
58+ push :
59+ branches :
60+ - main
61+ paths :
62+ - ' build/dockerfile'
63+ - ' build/requirements.txt'
64+ - ' build/docker-compose.yml'
65+ - ' .github/workflows/build.yml'
66+
67+ jobs :
68+ build-and-push :
69+ runs-on : ubuntu-latest
70+ permissions :
71+ contents : read
72+ packages : write
73+ env :
74+ IMAGE_NAME : ghcr.io/${{ github.repository }}
75+
76+ steps :
77+ - name : Checkout repository
78+ uses : actions/checkout@v4
79+
80+ - name : Lowercase the image name
81+ run : echo "IMAGE_NAME=${IMAGE_NAME,,}" >> $GITHUB_ENV
82+
83+ - name : Log in to GitHub Container Registry
84+ uses : docker/login-action@v3
85+ with :
86+ registry : ghcr.io
87+ username : ${{ github.actor }}
88+ password : ${{ secrets.GITHUB_TOKEN }}
89+
90+ - name : Build Docker image with Compose
91+ run : docker compose -f build/docker-compose.yml build
92+
93+ - name : Tag Docker images
94+ run : |
95+ docker tag "$IMAGE_NAME:latest" "$IMAGE_NAME:latest"
96+ docker tag "$IMAGE_NAME:latest" "$IMAGE_NAME:git-${GITHUB_SHA::7}"
97+
98+ - name : Push Docker images
99+ run : |
100+ docker push "$IMAGE_NAME:latest"
101+ docker push "$IMAGE_NAME:git-${GITHUB_SHA::7}"
102+
You can’t perform that action at this time.
0 commit comments