From 609b5ce65bdd0b46b68358ccd5e72f6596b2639a Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 22 Nov 2022 17:15:37 +0100 Subject: [PATCH] workflows,scripts: migrate to use GITHUB_OUTPUT Signed-off-by: Patrik Oldsberg --- .github/workflows/deploy_docker-image.yml | 2 +- .github/workflows/pr-review-comment.yaml | 2 +- .github/workflows/verify_docs-quality.yml | 2 +- scripts/check-if-release.js | 9 +++++++-- scripts/create-release-tag.js | 11 +++++++++-- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy_docker-image.yml b/.github/workflows/deploy_docker-image.yml index e5564f141f..f5dc164737 100644 --- a/.github/workflows/deploy_docker-image.yml +++ b/.github/workflows/deploy_docker-image.yml @@ -44,7 +44,7 @@ jobs: - name: find location of global yarn cache id: yarn-cache if: steps.cache-modules.outputs.cache-hit != 'true' - run: echo "::set-output name=dir::$(yarn cache dir)" + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT - name: cache global yarn cache uses: actions/cache@v3 diff --git a/.github/workflows/pr-review-comment.yaml b/.github/workflows/pr-review-comment.yaml index 6104a802d9..b51d73c4ad 100644 --- a/.github/workflows/pr-review-comment.yaml +++ b/.github/workflows/pr-review-comment.yaml @@ -33,7 +33,7 @@ jobs: } const prNumber = artifact.name.slice('pr_number-'.length) - console.log(`::set-output name=pr-number::${prNumber}`); + core.setOutput('pr-number', prNumber); - uses: backstage/actions/re-review@v0.5.7 with: diff --git a/.github/workflows/verify_docs-quality.yml b/.github/workflows/verify_docs-quality.yml index 736f09571f..dc1d942e32 100644 --- a/.github/workflows/verify_docs-quality.yml +++ b/.github/workflows/verify_docs-quality.yml @@ -18,7 +18,7 @@ jobs: # also contains an "--config=.github/vale/config.ini" option - name: generate vale args id: generate - run: echo "::set-output name=args::$(node scripts/check-docs-quality.js --ci-args)" + run: echo "args=$(node scripts/check-docs-quality.js --ci-args)" >> $GITHUB_OUTPUT - name: documentation quality check uses: errata-ai/vale-action@v2.0.1 diff --git a/scripts/check-if-release.js b/scripts/check-if-release.js index b61b0e2eb7..e7dabe14a4 100755 --- a/scripts/check-if-release.js +++ b/scripts/check-if-release.js @@ -28,6 +28,7 @@ const { execFile: execFileCb } = require('child_process'); const { resolve: resolvePath } = require('path'); const { promises: fs } = require('fs'); const { promisify } = require('util'); +const { EOL } = require('os'); const parentRef = process.env.COMMIT_SHA_BEFORE || 'HEAD^'; @@ -53,6 +54,10 @@ async function runPlain(cmd, ...args) { async function main() { process.cwd(resolvePath(__dirname, '..')); + if (!process.env.GITHUB_OUTPUT) { + throw new Error('GITHUB_OUTPUT environment variable not set'); + } + const diff = await runPlain( 'git', 'diff', @@ -103,7 +108,7 @@ async function main() { if (newVersions.length === 0) { console.log('No package version bumps detected, no release needed'); - console.log(`::set-output name=needs_release::false`); + await fs.appendFile(process.env.GITHUB_OUTPUT, `needs_release=false${EOL}`); return; } @@ -114,7 +119,7 @@ async function main() { ` ${name.padEnd(maxLength, ' ')} ${oldVersion} to ${newVersion}`, ); } - console.log(`::set-output name=needs_release::true`); + await fs.appendFile(process.env.GITHUB_OUTPUT, `needs_release=true${EOL}`); } main().catch(error => { diff --git a/scripts/create-release-tag.js b/scripts/create-release-tag.js index a2706c578f..28417024fd 100755 --- a/scripts/create-release-tag.js +++ b/scripts/create-release-tag.js @@ -19,6 +19,7 @@ const { Octokit } = require('@octokit/rest'); const path = require('path'); const fs = require('fs-extra'); +const { EOL } = require('os'); const baseOptions = { owner: 'backstage', @@ -64,6 +65,9 @@ async function main() { if (!process.env.GITHUB_TOKEN) { throw new Error('GITHUB_TOKEN is not set'); } + if (!process.env.GITHUB_OUTPUT) { + throw new Error('GITHUB_OUTPUT environment variable not set'); + } const commitSha = process.env.GITHUB_SHA; const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN }); @@ -74,8 +78,11 @@ async function main() { console.log(`Creating release tag ${tagName} at ${commitSha}`); await createGitTag(octokit, commitSha, tagName); - console.log(`::set-output name=tag_name::${tagName}`); - console.log(`::set-output name=version::${releaseVersion}`); + await fs.appendFile(process.env.GITHUB_OUTPUT, `tag_name=${tagName}${EOL}`); + await fs.appendFile( + process.env.GITHUB_OUTPUT, + `version=${releaseVersion}${EOL}`, + ); } main().catch(error => {