-
Notifications
You must be signed in to change notification settings - Fork 7
57 lines (52 loc) · 1.77 KB
/
docker-publish.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
46
47
48
49
50
51
52
53
54
55
56
57
name: Docker
on:
push:
branches:
- 'main'
- 'release/*'
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v4
# Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Login to GitHub Container Registry
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: set lower case owner name
run: |
echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV}
env:
OWNER: '${{ github.repository_owner }}'
# Determine the Docker tag name based on the branch name
- name: Set Docker tag name
run: |
# If the branch is 'main', set the tag name to 'latest'
if [[ "${GITHUB_REF#refs/heads/}" == "main" ]]; then
echo "DOCKER_TAG_NAME=latest" >> $GITHUB_ENV
# If the branch is a release branch, extract the release name
elif [[ "${GITHUB_REF#refs/heads/}" == release/* ]]; then
# Extract the release name and set it as the tag name
RELEASE_NAME=$(echo "${GITHUB_REF#refs/heads/release/}")
echo "DOCKER_TAG_NAME=${RELEASE_NAME}" >> $GITHUB_ENV
fi
# Build and push Docker image to GitHub Container Registry
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
# Use the branch name as the tag for the Docker image
tags: ghcr.io/${{ env.OWNER_LC }}/vocode-next-template:${{ env.DOCKER_TAG_NAME }}