-
Notifications
You must be signed in to change notification settings - Fork 2
120 lines (115 loc) · 4.4 KB
/
smart-contract-action.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
name: Smart Contract Action Build Push Test
# Build & Push builds the simapp docker image on every push to master
# and pushes the image to https://hub.docker.com/u/provenanceio
on:
pull_request:
branches:
- main
push:
branches:
- main
tags:
- "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0, v20.15.10
- "v[0-9]+.[0-9]+.[0-9]+-rc*" # Push events to matching v*, i.e. v1.0-rc1, v20.15.10-rc5
# Set concurrency for this workflow to cancel in-progress jobs if retriggered.
# The github.ref is only available when triggered by a PR so fall back to github.run_id for other cases.
# The github.run_id is unique for each run, giving each such invocation it's own unique concurrency group.
# Basically, if you push to a PR branch, jobs that are still running for that PR will be cancelled.
# But jobs started because of a merge to main or a release tag push are not cancelled.
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
jobs:
docker:
runs-on: ubuntu-latest
outputs:
smart_contract_action_version: ${{ steps.prep.outputs.version }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=provenanceio/smart-contract-action
VERSION=${{ github.event.pull_request.head.sha }}
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
fi
echo "Setting output: version=${VERSION}"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "Setting output: tags=${TAGS}"
echo "tags=${TAGS}" >> "$GITHUB_OUTPUT"
created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
echo "Setting output: created=$created"
echo "created=$created" >> "$GITHUB_OUTPUT"
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Publish to Docker Hub
uses: docker/build-push-action@v4
with:
context: smart-contract-action
build-args: |
VERSION=${{ steps.prep.outputs.version }}
platforms: linux/amd64
file: smart-contract-action/Dockerfile
push: true
tags: ${{ steps.prep.outputs.tags }}
test_with_provenance_release:
needs: docker
runs-on: ubuntu-latest
name: Test with provenance release with proposals
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Smart Contract Action
uses: ./
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
provenance_version: "v1.19.0-rc2"
smart_contract_action_version: ${{ needs.docker.outputs.smart_contract_action_version }}
test_script: "./smart-contract-action/test/test.sh"
test_with_provenance_release_no_script:
needs: docker
runs-on: ubuntu-latest
name: Test with provenance release without proposals
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Smart Contract Action
uses: ./
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
provenance_version: "v1.19.0-rc2"
smart_contract_action_version: ${{ needs.docker.outputs.smart_contract_action_version }}
test_with_init_data:
needs: docker
runs-on: ubuntu-latest
name: Test with provenance release without proposals
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Smart Contract Action
uses: ./
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
provenance_version: "v1.19.0-rc2"
smart_contract_action_version: ${{ needs.docker.outputs.smart_contract_action_version }}
init_data: "./smart-contract-action/test/init_data"