Skip to content

Commit 677d3a1

Browse files
committed
Split signing and deploy stages, prepare for pushing deployment
1 parent d6b0fe4 commit 677d3a1

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

.gitlab-ci.yml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ workflow:
66
stages:
77
- test
88
- package
9+
- deploy
910

1011
.build_and_test: &build_and_test
1112
stage: test
@@ -39,11 +40,11 @@ node:24:
3940
- npm run build-web
4041
artifacts:
4142
name: web
42-
expire_in: 20 minutes
43+
expire_in: 20 minutes # latest build does not expire until there is a new successful build https://gitlab.com/gitlab-org/gitlab/-/issues/36358#note_2232186823
4344
paths:
4445
- web-bundle.zip
4546

46-
pages:
47+
sign:
4748
stage: package
4849
rules:
4950
- if: '$CI_COMMIT_BRANCH == "main"'
@@ -53,11 +54,29 @@ pages:
5354
- node:24
5455
environment: sign # grant access to SIGNING_KEY and SIGNING_KEY_PASS project variables
5556
script:
56-
- apk add --update --no-cache openssl unzip
57+
- apk add --update --no-cache openssl
5758
- openssl dgst -sha256 -sign "$SIGNING_KEY" -passin "file:$SIGNING_KEY_PASS" -out web-bundle.zip.sign web-bundle.zip
58-
- unzip web-bundle.zip && mv web-bundle.zip web-bundle.zip.sign static/
5959
artifacts:
60-
expire_in: 20 minutes # safe to delete: https://gitlab.com/gitlab-org/gitlab/-/issues/36358#note_2232186823
60+
expire_in: 20 minutes
61+
paths:
62+
- web-bundle.zip
63+
- web-bundle.zip.sign
64+
65+
deploy:
66+
stage: deploy
67+
rules:
68+
- if: '$CI_COMMIT_BRANCH == "main"'
69+
dependencies:
70+
- sign
71+
environment: deploy # grant access to DEPLOY_SIGNING_KEY and DEPLOY_SIGNING_KEY_PASS project variables
72+
script:
73+
- POST_DETAIL="$(date -u '+%Y-%m-%dT%H:%M:%SZ');qr"
74+
- POST_SIGN="$(printf '%s' "$POST_DETAIL" | openssl dgst -sha256 -sign "$DEPLOY_SIGNING_KEY" -passin "file:$DEPLOY_SIGNING_KEY_PASS" -hex -)"
75+
#- curl -X POST --data-urlencode "detail=$POST_DETAIL" --data-urlencode "signature=$POST_SIGN" 'https://davidje13.com/cd/deploy'
76+
- apk add --update --no-cache unzip
77+
- unzip web-bundle.zip
78+
artifacts:
79+
expire_in: 20 minutes
6180
paths:
6281
- static
6382
pages:

0 commit comments

Comments
 (0)