-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (37 loc) · 1.18 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
39
40
41
42
43
44
45
name: Docker Image CI
on:
push:
branches: [main]
jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
env:
IMAGE_NAME: ${{ github.repository }}
steps:
- name: Check out the repository
uses: actions/checkout@v3
- name: Convert IMAGE_NAME to lowercase
run: |
echo "IMAGE_NAME=${IMAGE_NAME,,}" >> $GITHUB_ENV
- name: Build the Docker image
run: |
docker build . --file Dockerfile --tag $IMAGE_NAME:${{ github.sha }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Tag the image with the 'latest' tag
run: |
docker tag $IMAGE_NAME:${{ github.sha }} ghcr.io/$IMAGE_NAME:latest
- name: Tag the image with the SHA
run: |
docker tag $IMAGE_NAME:${{ github.sha }} ghcr.io/$IMAGE_NAME:${{ github.sha }}
- name: Push the Docker image to GitHub Container Registry
run: |
docker push ghcr.io/$IMAGE_NAME:latest
docker push ghcr.io/$IMAGE_NAME:${{ github.sha }}