-
Notifications
You must be signed in to change notification settings - Fork 9
91 lines (80 loc) · 2.74 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
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Docker
on:
push:
branches:
- main
tags:
- '*'
pull_request:
branches:
- main
jobs:
build-and-push-docker-image:
if: github.repository_owner == 'pitkley' && github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
#- name: Setup connection to arm64-capable runner
# run: |
# echo "::group::ssh-agent: launch and export"
# eval "$(ssh-agent)"
# echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> $GITHUB_ENV
# echo "SSH_AGENT_PID=$SSH_AGENT_PID" >> $GITHUB_ENV
# echo "::endgroup::"
# echo "::group::ssh-agent: load private key"
# ssh-add - <<< "${{ secrets.ARMRUNNER1_SSH_PRIVATE_KEY }}"
# echo "::endgroup::"
# echo "::group::ssh: pin runner public key"
# mkdir ~/.ssh && chmod 0700 ~/.ssh || :
# echo "[${{ secrets.ARMRUNNER1_HOSTNAME }}]:${{ secrets.ARMRUNNER1_SSH_PORT }} ${{ secrets.ARMRUNNER1_SSH_HOSTKEY }}" > ~/.ssh/known_hosts
# echo "::endgroup::"
#- name: Register arm64-capable runner with Buildx
# env:
# DOCKER_HOST: ssh://github-actions@${{ secrets.ARMRUNNER1_HOSTNAME }}:${{ secrets.ARMRUNNER1_SSH_PORT }}
# run: docker buildx create --append --name ${{ steps.buildx.outputs.name }} --bootstrap
- name: Checkout
uses: actions/checkout@v2
- name: Prepare Docker image tags
id: docker-image-tags
uses: haya14busa/action-cond@v1
with:
cond: ${{ github.event_name == 'push' }}
if_true: |
pitkley/dfw
ghcr.io/pitkley/dfw
if_false: |
ghcr.io/pitkley/dfw
- name: Prepare Docker image metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ steps.docker-image-tags.outputs.value }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Login to Docker Hub
if: github.event_name == 'push'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESSTOKEN }}
- name: Login to ghcr.io
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64
#platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}