-
-
Notifications
You must be signed in to change notification settings - Fork 4
55 lines (50 loc) · 1.67 KB
/
ci.yaml
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
name: CI
on:
push:
tags:
- "*"
workflow_dispatch:
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
with:
fetch-depth: 2
- uses: docker-practice/actions-setup-docker@master
- uses: azure/docker-login@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: azure/docker-login@v1
with:
login-server: ghcr.io
username: khs1994
password: ${{ secrets.GHCR_IO_TOKEN }}
- run: |
export GITHUB_TAG=$(echo $GITHUB_REF | cut -d '/' -f 3)
# DOCKER_PUSH="--load"
DOCKER_PUSH="--push"
DOCKER_LATEST_TAG="dev"
if ! [ "$GITHUB_EVENT_NAME" = 'workflow_dispatch' ];then
DOCKER_IMAGES="-t ${DOCKER_IMAGE}:${GITHUB_TAG} \
-t ${REGISTRY_MIRROR}/${DOCKER_IMAGE}:${GITHUB_TAG} \
-t ${DOCKER_IMAGE}:alpine \
-t ${REGISTRY_MIRROR}/${DOCKER_IMAGE}:alpine \
"
DOCKER_PUSH="--push"
DOCKER_LATEST_TAG="latest"
fi
docker buildx build \
-t ${DOCKER_IMAGE}:${DOCKER_LATEST_TAG} \
-t ${REGISTRY_MIRROR}/${DOCKER_IMAGE}:${DOCKER_LATEST_TAG} \
${DOCKER_IMAGES} \
${DOCKER_PUSH} \
--cache-from=ghcr.io/${DOCKER_IMAGE}:cache \
--cache-to=ghcr.io/${DOCKER_IMAGE}:cache \
.
env:
REGISTRY_MIRROR: ghcr.io
GITHUB_EVENT_NAME: ${{github.event_name}}
DOCKER_IMAGE: khs1994/acme
name: Build docker image