-
Notifications
You must be signed in to change notification settings - Fork 11
40 lines (33 loc) · 1.13 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
name: Docker
on: [push]
env:
IMAGE_NAME: chiya
REPOSITORY: ghcr.io
jobs:
push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Prepare metadata for build
id: prep
run: |
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
fi
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo ::set-output name=version::${VERSION}
- name: Build and publish Docker image (using cache)
uses: whoan/docker-build-with-cache-action@v5
with:
registry: ${{ env.REPOSITORY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
image_name: ${{ env.IMAGE_NAME }}
image_tag: ${{ steps.prep.outputs.version }}