Skip to content

Commit bce55ef

Browse files
authored
chore: create or update contracts (#40)
Signed-off-by: Miguel Martinez <[email protected]>
1 parent 1e19b4d commit bce55ef

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

.github/workflows/chainloop_contract_sync.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,23 @@ jobs:
2828
with:
2929
fetch-depth: 0
3030

31-
- name: Update contracts ${{ inputs.contract_root_folder }} on Chainloop
31+
- name: Sync contracts ${{ inputs.contract_root_folder }} on Chainloop
3232
run: |
33-
for file in $(ls ${{ inputs.contract_root_folder }}); do
34-
if [[ $file = *.yml || $file = *.yaml ]]; then
35-
contract_name=$(basename $file | cut -d'.' -f1)
36-
echo "Updating contract $contract_name with ${{ inputs.contract_root_folder }}/$file"
37-
chainloop wf contract update --name $contract_name --contract ${{ inputs.contract_root_folder }}/$file
38-
fi
39-
done
33+
for file in $(ls ${{ inputs.contract_root_folder }}); do
34+
if [[ $file = *.yml || $file = *.yaml ]]; then
35+
contract_name=$(basename $file | cut -d'.' -f1)
36+
contract_file="${{ inputs.contract_root_folder }}/$file"
37+
38+
echo "Checking if contract $contract_name exists..."
39+
if chainloop wf contract describe --name $contract_name >/dev/null 2>&1; then
40+
echo "Contract $contract_name exists, updating..."
41+
chainloop wf contract update --name $contract_name --contract $contract_file
42+
else
43+
echo "Contract $contract_name does not exist, creating..."
44+
chainloop wf contract create --name $contract_name --contract $contract_file
45+
fi
46+
fi
47+
done
4048
4149
env:
4250
CHAINLOOP_VERSION: ${{ inputs.chainloop_version }}

0 commit comments

Comments
 (0)