-
Notifications
You must be signed in to change notification settings - Fork 15
87 lines (72 loc) · 2.49 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
name: Docker Build
on:
pull_request:
branches:
- main
- classic
push:
branches:
- main
- classic
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
# https://docs.docker.com/build/ci/github-actions/multi-platform/
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ap-northeast-2
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Log in to the github container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# https://github.com/docker/login-action
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
images: |
${{ steps.login-ecr.outputs.registry }}/${{ github.event.repository.name }}
ghcr.io/${{ github.repository }}
terraformlabs/${{ github.event.repository.name }}
tags: |
type=sha
type=edge,branch=test
type=semver,pattern={{tag}}
type=semver,pattern={{version}}
type=raw,value=latest,event=branch,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=classic,event=branch,enable=${{ github.ref == format('refs/heads/{0}', 'classic') }}
- name: Build docker image
uses: docker/build-push-action@v3
with:
push: ${{ github.event_name != 'pull_request' }}
file: Dockerfile
platforms: linux/amd64
tags: ${{ env.DOCKER_METADATA_OUTPUT_TAGS }}
labels: ${{ env.DOCKER_METADATA_OUTPUT_LABELS }}