-
Notifications
You must be signed in to change notification settings - Fork 1
66 lines (56 loc) · 2.25 KB
/
docker-tiddlywiki.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
58
59
60
61
62
63
64
65
66
name: tiddlywiki container image
on:
workflow_dispatch: {}
jobs:
build-docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
path: main
- uses: actions/checkout@v2
with:
repository: 'elasticdog/tiddlywiki-docker'
path: tiddlywiki
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Get docker environment
id: env
working-directory: ./tiddlywiki
env:
PACKAGE_NAME: tiddlywiki
run: |
set -x
[[ -z "$DOCKER_HUB_USERNAME" ]] && DOCKER_HUB_USERNAME="$(awk -F / '{print $1}' <<< "$GITHUB_REPOSITORY")"
[[ -z "$PACKAGE_NAME" ]] && PACKAGE_NAME="$(basename -s .git "$(git config --get remote.origin.url)")"
DOCKER_TAG="$(git log --format="%H" -n 1)"
DOCKER_HUB_URL="$DOCKER_HUB_USERNAME/$PACKAGE_NAME"
DOCKER_IMAGE="$DOCKER_HUB_URL:$DOCKER_TAG"
DOCKER_IMAGE_CACHE="$DOCKER_HUB_URL:cache"
DOCKER_IMAGE_LATEST="$DOCKER_HUB_URL:latest"
echo "::set-output name=PACKAGE_DIR::$(basename $PWD)"
echo "::set-output name=PACKAGE_NAME::$PACKAGE_NAME"
echo "::set-output name=DOCKER_HUB_USERNAME::$DOCKER_HUB_USERNAME"
echo "::set-output name=DOCKER_IMAGE::$DOCKER_IMAGE"
echo "::set-output name=DOCKER_IMAGE_LATEST::$DOCKER_IMAGE_LATEST"
echo "::set-output name=DOCKER_IMAGE_CACHE::$DOCKER_IMAGE_CACHE"
echo "::set-output name=DOCKER_TAGS::$DOCKER_IMAGE,$DOCKER_IMAGE_LATEST"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ steps.env.outputs.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ${{ steps.env.outputs.PACKAGE_DIR }}
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.env.outputs.DOCKER_TAGS }}
cache-from: ${{ steps.env.outputs.DOCKER_IMAGE_CACHE }}
cache-to: ${{ steps.env.outputs.DOCKER_IMAGE_CACHE }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}