-
Notifications
You must be signed in to change notification settings - Fork 4
35 lines (29 loc) · 1.18 KB
/
docker.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
name: Build and Push Docker Image
on:
push:
branches:
- main # Trigger on pushes to the main branch
jobs:
build_and_push:
runs-on: ubuntu-latest
steps:
# This step is a workaround for an issue whereby github artifacts expects repositories to have only lower case names
# See https://github.com/docker/build-push-action/issues/37
- name: PrepareReg Names
run: |
echo IMAGE_REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
echo IMAGE_TAG=$(echo ${{ github.ref }} | tr '[:upper:]' '[:lower:]' | awk '{split($0,a,"/"); print a[3]}') >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push with commit SHA tag
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ghcr.io/${{ env.IMAGE_REPOSITORY }}:latest, ghcr.io/${{ env.IMAGE_REPOSITORY }}:${{ github.sha }}