-
Notifications
You must be signed in to change notification settings - Fork 38
88 lines (86 loc) · 3.31 KB
/
workflow-build.yaml
File metadata and controls
88 lines (86 loc) · 3.31 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
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
name: Build Docker Images
on:
push:
branches: ['main', 'feat/api']
jobs:
build-deploy:
runs-on: ubuntu-latest
strategy:
matrix:
service:
[
api,
api-user,
app,
frontend,
backend,
indexer-balance,
indexer-base,
indexer-events,
indexer-dex,
indexer-multichain,
indexer-signature,
indexer-staking,
indexer-receipts,
indexer-s3,
indexer-accounts,
indexer-contract,
explorer-selector,
aggregates,
block-proxy,
]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Determine image tag
run: |
if [ "${{ matrix.service }}" = "api" ] || [ "${{ matrix.service }}" = "indexer-base" ] || [ "${{ matrix.service }}" = "indexer-receipts" ] || [ "${{ matrix.service }}" = "indexer-balance" ] || [ "${{ matrix.service }}" = "indexer-events" ] || [ "${{ matrix.service }}" = "backend" ] || [ "${{ matrix.service }}" = "aggregates" ]; then
echo "TAG=:v2" >> $GITHUB_ENV
else
echo "TAG=:latest" >> $GITHUB_ENV
fi
- name: Get current image digest
run: |
CURRENT_DIGEST=$(docker manifest inspect ghcr.io/nearblocks/${{ matrix.service }}${{ env.TAG }} | jq -r '.config.digest' || echo "")
echo "CURRENT_DIGEST=$CURRENT_DIGEST" >> $GITHUB_ENV
- uses: docker/build-push-action@v5
id: build
with:
context: .
file: apps/${{ matrix.service }}/Dockerfile
platforms: linux/amd64
push: true
provenance: false
tags: |
ghcr.io/nearblocks/${{ matrix.service }}${{ env.TAG }}
ghcr.io/nearblocks/${{ matrix.service }}:${{ github.sha }}
cache-from: type=registry,ref=ghcr.io/nearblocks/${{ matrix.service }}${{ env.TAG }}
cache-to: type=inline
build-args: |
GITHUB_SHA=${{ github.sha }}
NEXT_SERVER_ACTIONS_ENCRYPTION_KEY=${{ secrets.NEXT_SERVER_ACTIONS_ENCRYPTION_KEY }}
- name: Get new image digest
run: |
NEW_DIGEST=$(docker manifest inspect ghcr.io/nearblocks/${{ matrix.service }}${{ env.TAG }} | jq -r '.config.digest')
echo "NEW_DIGEST=$NEW_DIGEST" >> $GITHUB_ENV
# - name: Deploy testnet
# if: |
# env.CURRENT_DIGEST != env.NEW_DIGEST &&
# matrix.service != 'indexer-dex' &&
# matrix.service != 'indexer-s3' &&
# matrix.service != 'explorer-selector'
# run: |
# echo "${{ secrets.KUBE_CONFIG }}" | base64 -d > kubeconfig
# export KUBECONFIG=$(pwd)/kubeconfig
#
# kubectl set -n nearblocks-testnet image deployment/testnet-${{ matrix.service }} ${{ matrix.service }}=ghcr.io/nearblocks/${{ matrix.service }}:${{ github.sha }}
# kubectl rollout -n nearblocks-testnet status deployment/testnet-${{ matrix.service }} --timeout=600s