-
Notifications
You must be signed in to change notification settings - Fork 136
38 lines (32 loc) · 1.14 KB
/
docker-image.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
name: Docker Image CI
on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Login step only executed for pushes to main
- name: Login to GitHub Container Registry
if: github.ref == 'refs/heads/master'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GH_Token }}
# Build and tag the production Docker image
- name: Build the Docker image
run: |
docker build . --file Dockerfile --tag ghcr.io/${{ github.repository }}:${{ github.sha }}
if [ "${{ github.ref }}" == "refs/heads/master" ]; then
docker tag ghcr.io/${{ github.repository }}:${{ github.sha }} ghcr.io/${{ github.repository }}:latest
fi
# Push the production Docker image
- name: Push the Docker image
if: github.ref == 'refs/heads/master'
run: |
docker push ghcr.io/${{ github.repository }}:${{ github.sha }}
docker push ghcr.io/${{ github.repository }}:latest