-
Notifications
You must be signed in to change notification settings - Fork 2
139 lines (122 loc) · 4.23 KB
/
chains.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
name: chains-build
on:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main
tags:
- 'v*'
env:
AWS_REGION: "us-east-1"
AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY }}"
AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_KEY }}"
AWS_DEFAULT_OUTPUT: "json"
jobs:
# JOB to run change detection
filtered:
runs-on: ubuntu-latest
# Required permissions
permissions:
contents: read
pull-requests: read
outputs:
# Expose matched filters as job output variable
upgrades: ${{ steps.choice.outputs.upgrades_files }}
steps:
- name: Checkout
uses: actions/checkout@v3
- id: filter
uses: dorny/paths-filter@v2
with:
list-files: 'json'
filters: |
upgrades: 'chains/*/upgrades.yml'
- id: choice
shell: bash
run: |
if [[ "${{ github.event.ref }}" == "refs/tags/v"* ]]; then
echo "upgrades_files=$(echo "[\"$(ls -d chains/*/upgrades.* | paste -sd ',' | sed -e 's/,/","/g')\"]")" >> "$GITHUB_OUTPUT"
else
echo 'upgrades_files=${{ steps.filter.outputs.upgrades_files }}' >> "$GITHUB_OUTPUT"
fi
build:
needs: filtered
strategy:
fail-fast: false
matrix:
upgrades: ${{ fromJSON(needs.filtered.outputs.upgrades) }}
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@v3
with:
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Convert previous steps output to env var
run: |
echo "ECR_REGISTRY=${{ steps.login-ecr.outputs.registry }}" >> ${GITHUB_ENV}
- name: Log in to the github container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set env vars
shell: bash
run: |
CHAIN_DIR=$(basename $(dirname ${{ matrix.upgrades }}))
CHAIN_NAME=${CHAIN_DIR%%-*}
CHAIN_NETWORK=${CHAIN_DIR##*-}
SUFFIX=${CHAIN_DIR#*-}
echo "CHAIN_DIR=${CHAIN_DIR}" >> $GITHUB_ENV
echo "CHAIN_NAME=${CHAIN_NAME}" >> $GITHUB_ENV
echo "CHAIN_NETWORK=${CHAIN_NETWORK}" >> $GITHUB_ENV
echo "TAG_PREFIX=${CHAIN_NAME}-${CHAIN_NETWORK}-" >> $GITHUB_ENV
if [[ "${SUFFIX}" != "${CHAIN_NETWORK}" ]]; then
echo "TAG_SUFFIX=-${SUFFIX%%-*}" >> $GITHUB_ENV
else
#echo "TAG_SUFFIX=\"\"" >> $GITHUB_ENV
echo "TAG_SUFFIX=" >> $GITHUB_ENV
fi
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
images: |
ghcr.io/${{ github.repository }}
${{ env.ECR_REGISTRY }}/cosmovisor
flavor: |
latest=false
tags: |
type=sha,prefix=${{ env.TAG_PREFIX }},suffix=${{ env.TAG_SUFFIX }}
type=semver,pattern={{version}},prefix=${{ env.TAG_PREFIX }},suffix=${{ env.TAG_SUFFIX }}
type=raw,value=${{ env.TAG_PREFIX }}latest${{ env.TAG_SUFFIX }},enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
- 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 }}
build-args: |
CHAIN_DIR=${{ env.CHAIN_DIR }}
CHAIN_NAME=${{ env.CHAIN_NAME }}
CHAIN_NETWORK=${{ env.CHAIN_NETWORK }}