-
Notifications
You must be signed in to change notification settings - Fork 2
63 lines (56 loc) · 2.03 KB
/
Copy pathdocker.yml
File metadata and controls
63 lines (56 loc) · 2.03 KB
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
name: docker
on:
push:
tags:
- v*
branches:
- master
jobs:
# Builds and pushes the Docker image to Docker Hub and ECR
push-to-registries:
runs-on: ubuntu-latest
steps:
- name: Prepare tags
id: tags
shell: python
run: |
import datetime
timestamp = str(int(datetime.datetime.now().timestamp()))
base_ecr_tag = '${{ secrets.AWS_ECR_URL }}:'
base_dockerhub_tag = 'docker.io/hathornetwork/tx-mining-service:'
tags = set()
ref = '${{ github.ref }}'
if ref.startswith('refs/tags/'):
version = ref[10:].split('-', 1)[0]
tags.add(base_ecr_tag + version)
tags.add(base_ecr_tag + 'latest')
tags.add(base_dockerhub_tag + version)
tags.add(base_dockerhub_tag + 'latest')
elif ref == 'refs/heads/master':
tags.add(base_ecr_tag + 'staging-${{ github.sha }}-' + timestamp)
else:
tags.add(base_ecr_tag + 'dev-${{ github.sha }}-' + timestamp)
print("::set-output name=tags::" + ",".join(tags))
- name: Set up QEMU
uses: docker/setup-qemu-action@27d0a4f181a40b142cce983c5393082c365d1480
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@94ab11c41e45d028884a99163086648e898eed25
- name: Login to DockerHub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to AWS ECR
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ secrets.AWS_ECR_URL}}
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Build and push
uses: docker/build-push-action@a66e35b9cbcf4ad0ea91ffcaf7bbad63ad9e0229
with:
push: true
tags: ${{ steps.tags.outputs.tags }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max