-
Notifications
You must be signed in to change notification settings - Fork 2
51 lines (45 loc) · 1.71 KB
/
chainloop_contract_sync.yml
File metadata and controls
51 lines (45 loc) · 1.71 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
name: Chainloop Contract Sync
on:
workflow_call:
inputs:
chainloop_version:
required: false
type: string
contract_root_folder:
required: false
type: string
default: .github/workflows/contracts
secrets:
api_token:
required: true
jobs:
chainloop_contract_sync:
name: Chainloop Install
runs-on: ubuntu-latest
steps:
- name: Install Chainloop
run: |
curl -sfL https://docs.chainloop.dev/install.sh | bash -s -- --version v${{ env.CHAINLOOP_VERSION }}
- name: Checkout repository
uses: actions/checkout@v4.1.4
with:
fetch-depth: 0
- name: Sync contracts ${{ inputs.contract_root_folder }} on Chainloop
run: |
for file in $(ls ${{ inputs.contract_root_folder }}); do
if [[ $file = *.yml || $file = *.yaml ]]; then
contract_name=$(basename $file | cut -d'.' -f1)
contract_file="${{ inputs.contract_root_folder }}/$file"
echo "Checking if contract $contract_name exists..."
if chainloop wf contract describe --name $contract_name >/dev/null 2>&1; then
echo "Contract $contract_name exists, updating..."
chainloop wf contract update --name $contract_name --contract $contract_file
else
echo "Contract $contract_name does not exist, creating..."
chainloop wf contract create --name $contract_name --contract $contract_file
fi
fi
done
env:
CHAINLOOP_VERSION: ${{ inputs.chainloop_version }}
CHAINLOOP_TOKEN: ${{ secrets.api_token }}