-
Notifications
You must be signed in to change notification settings - Fork 1
142 lines (132 loc) · 5.46 KB
/
release.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Release Image
on:
push:
branches:
- main
- release
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
SERVICE_NAME: nfts-solana
DOCKERHUB_REPO: ${{ vars.DOCKERHUB_ORG }}/${{ github.event.repository.name }}
DOCKERHUB_MIGRATIONS_REPO: ${{ vars.DOCKERHUB_ORG }}/${{ github.event.repository.name }}-migrations
DOCKERHUB_INDEXER_REPO: ${{ vars.DOCKERHUB_ORG }}/${{ github.event.repository.name }}-indexer
CACHE_CONFIG: type=s3,region=${{ vars.AWS_REGION }},bucket=${{ vars.AWS_BUCKET }},access_key_id=${{ secrets.AWS_ACCESS_KEY_ID }},secret_access_key=${{ secrets.AWS_SECRET_ACCESS_KEY }}
jobs:
build:
strategy:
matrix:
arch: [amd64, arm64]
runs-on: ${{ matrix.arch }}
environment: release
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
run: |
docker context create ci
docker context use ci
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: image=moby/buildkit:master
version: v0.10.4
endpoint: ci
-
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ vars.AWS_REGION }}
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
-
name: Build and push ${{ github.event.repository.name }}
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
target: ${{ github.event.repository.name }}
push: true
provenance: false
platforms: linux/${{ matrix.arch }}
tags: ${{ vars.DOCKERHUB_ORG }}/${{ github.event.repository.name }}:latest-${{ matrix.arch }}
cache-from: ${{ env.CACHE_CONFIG }},prefix=buildx/${{ github.event.repository.name }}/${{ matrix.arch }}/
cache-to: ${{ env.CACHE_CONFIG }},prefix=buildx/${{ github.event.repository.name }}/${{ matrix.arch }}/,mode=max
-
name: Build and push ${{ github.event.repository.name }}-migrations
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
target: migrator
push: true
provenance: false
platforms: linux/${{ matrix.arch }}
tags: ${{ vars.DOCKERHUB_ORG }}/${{ github.event.repository.name }}-migrations:latest-${{ matrix.arch }}
cache-from: ${{ env.CACHE_CONFIG }},prefix=buildx/${{ github.event.repository.name }}/${{ matrix.arch }}/
cache-to: ${{ env.CACHE_CONFIG }},prefix=buildx/${{ github.event.repository.name }}/${{ matrix.arch }}/,mode=max
-
name: Build and push ${{ github.event.repository.name }}-indexer
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
target: solana-indexer
push: true
provenance: false
platforms: linux/${{ matrix.arch }}
tags: ${{ vars.DOCKERHUB_ORG }}/${{ github.event.repository.name }}-indexer:latest-${{ matrix.arch }}
cache-from: ${{ env.CACHE_CONFIG }},prefix=buildx/${{ github.event.repository.name }}/${{ matrix.arch }}/
cache-to: ${{ env.CACHE_CONFIG }},prefix=buildx/${{ github.event.repository.name }}/${{ matrix.arch }}/,mode=max
finalize:
needs: build
runs-on: ubuntu-latest
environment: release
steps:
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Merge service image tags
uses: Noelware/docker-manifest-action@master
with:
inputs: ${{ env.DOCKERHUB_REPO }}:latest,${{ env.DOCKERHUB_REPO }}:${{ github.sha }}
images: ${{ env.DOCKERHUB_REPO }}:latest-amd64,${{ env.DOCKERHUB_REPO }}:latest-arm64
push: true
- name: Merge migrations image tags
uses: Noelware/docker-manifest-action@master
with:
inputs: ${{ env.DOCKERHUB_MIGRATIONS_REPO }}:latest,${{ env.DOCKERHUB_MIGRATIONS_REPO }}:${{ github.sha }}
images: ${{ env.DOCKERHUB_MIGRATIONS_REPO }}:latest-amd64,${{ env.DOCKERHUB_MIGRATIONS_REPO }}:latest-arm64
push: true
- name: Merge indexer image tags
uses: Noelware/docker-manifest-action@master
with:
inputs: ${{ env.DOCKERHUB_INDEXER_REPO }}:latest,${{ env.DOCKERHUB_INDEXER_REPO }}:${{ github.sha }}
images: ${{ env.DOCKERHUB_INDEXER_REPO }}:latest-amd64,${{ env.DOCKERHUB_INDEXER_REPO }}:latest-arm64
push: true
- name: Setup variables
id: vars
run: |
if [[ "${{ github.ref }}" == "refs/heads/release" ]]; then
echo "::set-output name=environment::prod"
else
echo "::set-output name=environment::stage"
fi
- name: Invoke workflow in hub-kubes repo
uses: benc-uk/workflow-dispatch@v1
with:
ref: main
token: ${{ secrets.ACTIONS_TOKEN }}
workflow: release.yml
repo: holaplex/hub-kubes
inputs: '{ "service": "${{ env.SERVICE_NAME }}", "environment": "${{ steps.vars.outputs.environment }}", "commit_hash": "${{ github.sha }}"}'