Skip to content

Commit 5c3e7aa

Browse files
committed
autodeploy: Update env-specific revision file
(cherry picked from commit 7e33921)
1 parent 9cbf03a commit 5c3e7aa

File tree

2 files changed

+38
-19
lines changed

2 files changed

+38
-19
lines changed

.github/workflows/deploy.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@ jobs:
1212
- name: Checkout
1313
uses: actions/checkout@v2
1414

15+
- name: Inject slug/short variables
16+
uses: rlespinasse/[email protected]
17+
1518
- name: Deploy to bitte
16-
run: ./scripts/deploy-bitte master
19+
run: ./scripts/deploy-bitte

scripts/deploy-bitte

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,36 @@ error () {
77
}
88

99
readonly ops_repo="input-output-hk/plutus-ops"
10+
readonly ops_branch="master"
1011
readonly plutus_rev="${GITHUB_SHA:-}"
12+
1113
if [ -z "${plutus_rev}" ]
1214
then
1315
error "GITHUB_SHA environment variable not set!"
1416
fi
1517

16-
### Argument parsing
18+
readonly plutus_ref="${GITHUB_REF_SLUG:-}"
1719

18-
if [ "$#" -ne 1 ]
20+
if [ -z "${plutus_ref}" ]
1921
then
20-
error "USAGE: $0 OPS_BRANCH"
22+
error "GITHUB_REF_SLUG environment variable not set!"
2123
fi
2224

23-
readonly ops_branch="$1"
25+
declare -A ref_env_mapping=(
26+
# TODO Make this the production branch
27+
[bitte]=production
28+
)
29+
30+
if [ ! -v 'ref_env_mapping[${plutus_ref}]' ]
31+
then
32+
error "Ref ${plutus_ref} does not correspond to any known env"
33+
fi
34+
plutus_env="${ref_env_mapping[${plutus_ref}]}"
35+
36+
if [ "$#" -ne 0 ]
37+
then
38+
error "USAGE: $0"
39+
fi
2440

2541
### Set up scratch space
2642

@@ -38,31 +54,31 @@ tmp="$(mktemp -d)"
3854

3955
declare -r tmp
4056

41-
### Write the new plutus-rev.cue
57+
### Write the new revision cue file
4258

43-
cat > "${tmp}/plutus-rev.cue" <<EOF
44-
package bitte
59+
cat > "${tmp}/${plutus_env}.cue" <<EOF
60+
package revisions
4561
46-
plutusRev: "${plutus_rev}"
62+
${plutus_env}: "${plutus_rev}"
4763
EOF
4864

4965

5066

51-
### Get the old plutus-rev.cue, exit if it's unchanged
52-
hub api -XGET -F ref="${ops_branch}" "/repos/${ops_repo}/contents/plutus-rev.cue" > "${tmp}/plutus-rev.cue-contents.json"
53-
prev_hash="$(jq --join-output '.sha' < "${tmp}/plutus-rev.cue-contents.json")"
54-
jq --join-output '.content' < "${tmp}/plutus-rev.cue-contents.json" | base64 -d > "${tmp}/plutus-rev-old.cue"
55-
if diff -q "${tmp}/plutus-rev.cue" "${tmp}/plutus-rev-old.cue" >/dev/null
67+
### Get the old revision cue file, exit if it's unchanged
68+
hub api -XGET -F ref="${ops_branch}" "/repos/${ops_repo}/contents/revisions/${plutus_env}.cue" > "${tmp}/${plutus_env}.cue-contents.json"
69+
prev_hash="$(jq --join-output '.sha' < "${tmp}/${plutus_env}.cue-contents.json")"
70+
jq --join-output '.content' < "${tmp}/${plutus_env}.cue-contents.json" | base64 -d > "${tmp}/${plutus_env}-old.cue"
71+
if diff -q "${tmp}/${plutus_env}.cue" "${tmp}/${plutus_env}-old.cue" >/dev/null
5672
then
5773
exit 0
5874
fi
5975

60-
### Commit the new plutus-rev.cue
61-
base64 "${tmp}/plutus-rev.cue" > "${tmp}/plutus-rev.cue-encoded"
62-
echo "Automatic update: Bump plutus to ${plutus_rev}" > "${tmp}/commit-message"
76+
### Commit the new revision cue file
77+
base64 "${tmp}/${plutus_env}.cue" > "${tmp}/${plutus_env}.cue-encoded"
78+
echo "${plutus_env}: Bump plutus to ${plutus_rev}" > "${tmp}/commit-message"
6379
hub api -XPUT \
6480
-F message=@"${tmp}/commit-message" \
65-
-F content=@"${tmp}/plutus-rev.cue-encoded" \
81+
-F content=@"${tmp}/${plutus_env}.cue-encoded" \
6682
-F sha="${prev_hash}" \
6783
-F branch="${ops_branch}" \
68-
"/repos/${ops_repo}/contents/plutus-rev.cue"
84+
"/repos/${ops_repo}/contents/revisions/${plutus_env}.cue"

0 commit comments

Comments
 (0)