From 526a0afb0dc1791e35efee9ac7cb7e6254feba17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Molinero=20Fern=C3=A1ndez?= Date: Thu, 28 Apr 2022 22:38:50 +0200 Subject: [PATCH] Use environment variable instead of context --- .github/workflows/main.yml | 6 ++++-- .github/workflows/rebuild-latest-release.yml | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e434d40..080b8a3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -93,17 +93,19 @@ jobs: contents: 'write' steps: - name: 'Create release' + env: + GITHUB_PAT: '${{ secrets.GITHUB_TOKEN }}' run: | RELEASE_STATUS="$(curl -fs --proto '=https' --tlsv1.3 --globoff \ --url "https://api.github.com/repos/${GITHUB_REPOSITORY:?}/releases/tags/${GITHUB_REF_NAME:?}" \ - --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ + --header "Authorization: Bearer ${GITHUB_PAT:?}" \ --header 'Accept: application/vnd.github.v3+json' \ --header 'Content-Type: application/json' \ --write-out '%{http_code}' --output /dev/null ||:)" if [ "${RELEASE_STATUS:?}" = '200' ]; then exit 0; fi RELEASE_ID="$(curl -fsS --proto '=https' --tlsv1.3 --globoff \ --url "https://api.github.com/repos/${GITHUB_REPOSITORY:?}/releases" \ - --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ + --header "Authorization: Bearer ${GITHUB_PAT:?}" \ --header 'Accept: application/vnd.github.v3+json' \ --header 'Content-Type: application/json' \ --data "$(jq -rn --arg tag "${GITHUB_REF_NAME:?}" '{"name": $tag, "tag_name": $tag, "generate_release_notes": true}')" | jq -r '.id')" diff --git a/.github/workflows/rebuild-latest-release.yml b/.github/workflows/rebuild-latest-release.yml index 25eb148..d589f02 100644 --- a/.github/workflows/rebuild-latest-release.yml +++ b/.github/workflows/rebuild-latest-release.yml @@ -12,21 +12,21 @@ jobs: runs-on: 'ubuntu-latest' permissions: contents: 'read' - env: - PERSONAL_GITHUB_TOKEN: '${{ secrets.PERSONAL_GITHUB_TOKEN }}' steps: - name: 'REST API call' + env: + GITHUB_PAT: '${{ secrets.PERSONAL_GITHUB_TOKEN }}' run: | RELEASE_TAG="$(curl -fsS --proto '=https' --tlsv1.3 --globoff \ --url "https://api.github.com/repos/${GITHUB_REPOSITORY:?}/releases/latest" \ - --header "Authorization: Bearer ${PERSONAL_GITHUB_TOKEN:?}" \ + --header "Authorization: Bearer ${GITHUB_PAT:?}" \ --header 'Accept: application/vnd.github.v3+json' \ --header 'Content-Type: application/json' \ | jq -rc '.tag_name')" if [ -n "${RELEASE_TAG-}" ] && [ "${RELEASE_TAG:?}" != 'null' ]; then curl -fsS --proto '=https' --tlsv1.3 --globoff \ --url "https://api.github.com/repos/${GITHUB_REPOSITORY:?}/actions/workflows/main.yml/dispatches" \ - --header "Authorization: Bearer ${PERSONAL_GITHUB_TOKEN:?}" \ + --header "Authorization: Bearer ${GITHUB_PAT:?}" \ --header 'Accept: application/vnd.github.v3+json' \ --header 'Content-Type: application/json' \ --data "$(jq -rn --arg tag "${RELEASE_TAG:?}" '{"ref": $tag}')"