@@ -262,18 +262,34 @@ jobs:
262262
263263 - name : Commit, push and tag the provider
264264 env :
265- PUSH_TOKEN : ${{ secrets.TF_PROVIDER_GITHUB_TOKEN }}
265+ # A deploy key with write access to terraform-provider-logstruct only. Deploy keys don't expire: the PAT
266+ # this replaced had expired by the 0.2.0 release.
267+ DEPLOY_KEY : ${{ secrets.TF_PROVIDER_DEPLOY_KEY }}
266268 run : |
269+ if [[ -z "$DEPLOY_KEY" ]]; then
270+ echo "::error::TF_PROVIDER_DEPLOY_KEY isn't set in the release environment."
271+ exit 1
272+ fi
273+ mkdir -p ~/.ssh && chmod 700 ~/.ssh
274+ printf '%s\n' "$DEPLOY_KEY" > ~/.ssh/provider_deploy_key
275+ chmod 600 ~/.ssh/provider_deploy_key
276+ # GitHub's published host keys, so the key is only ever offered to github.com
277+ curl -fsS https://api.github.com/meta | jq -r '.ssh_keys[] | "github.com " + .' > ~/.ssh/github_known_hosts
278+ export GIT_SSH_COMMAND="ssh -i $HOME/.ssh/provider_deploy_key -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile=$HOME/.ssh/github_known_hosts"
279+ REMOTE=git@github.com:DocSpring/terraform-provider-logstruct.git
280+ # Stop before changing anything if GitHub doesn't accept the key
281+ if ! git ls-remote "$REMOTE" HEAD >/dev/null; then
282+ echo "::error::GitHub didn't accept TF_PROVIDER_DEPLOY_KEY for terraform-provider-logstruct: check the repo's deploy key (with write access) matches the secret."
283+ exit 1
284+ fi
267285 git config --global user.name "DocSpring Bot"
268286 git config --global user.email "docspring-bot@docspring.com"
269- git clone https://github.com/DocSpring/terraform-provider-logstruct.git terraform-provider-logstruct
287+ git clone "$REMOTE" terraform-provider-logstruct
270288 cd terraform-provider-logstruct
271- # The token is passed to the two pushes only, not stored in the clone's config
272- AUTH="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$PUSH_TOKEN" | base64 -w0)"
273289 if [[ -s ../provider-changes.patch ]]; then
274290 git apply --index ../provider-changes.patch
275291 git commit -m "Sync catalog from logstruct $TAG_NAME"
276- git -c "http.https://github.com/.extraheader=$AUTH" push origin HEAD:main
292+ git push origin HEAD:main
277293 else
278294 echo "No provider changes to commit."
279295 fi
@@ -282,4 +298,4 @@ jobs:
282298 exit 0
283299 fi
284300 git tag -a "$TAG_NAME" -m "Release $TAG_NAME (logstruct sync)"
285- git -c "http.https://github.com/.extraheader=$AUTH" push origin "$TAG_NAME"
301+ git push origin "$TAG_NAME"
0 commit comments