diff --git a/.github/workflows/update-turbopack-test-manifest.yml b/.github/workflows/update-turbopack-test-manifest.yml new file mode 100644 index 0000000000000..121b0508febc2 --- /dev/null +++ b/.github/workflows/update-turbopack-test-manifest.yml @@ -0,0 +1,36 @@ +# A recurring workflow which updates the passing/failing/skipped integration tests for Turbopack. +name: Update Turbopack test manifest + +on: + schedule: + # Every hour + - cron: '0 * * * *' + workflow_dispatch: + +jobs: + update_manifest: + name: Update and upload Turbopack test manifest + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + # Commits made with the default `GITHUB_TOKEN` won't trigger workflows. + # See: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow + token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }} + + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_LTS_VERSION }} + check-latest: true + + - name: Create Pull Request + shell: bash + run: node scripts/automated-update-workflow.js + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PULL_REQUESTS }} + BRANCH_NAME: fonts-data + SCRIPT: test/build-turbopack-tests-manifest.js + PR_TITLE: Update Turbopack test manifest + PR_BODY: This auto-generated PR updates the integration test manifest used when testing Turbopack. diff --git a/.github/workflows/update_fonts_data.yml b/.github/workflows/update_fonts_data.yml index f1ba72107db19..3bda3c85850e1 100644 --- a/.github/workflows/update_fonts_data.yml +++ b/.github/workflows/update_fonts_data.yml @@ -36,6 +36,10 @@ jobs: - name: Create Pull Request shell: bash - run: node scripts/update-fonts-data-workflow.js + run: node scripts/automated-update-workflow.js env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PULL_REQUESTS }} + BRANCH_NAME: fonts-data + SCRIPT: scripts/update-google-fonts.js + PR_TITLE: Update font data + PR_BODY: This auto-generated PR updates font data with latest available diff --git a/scripts/update-fonts-data-workflow.js b/scripts/automated-update-workflow.js similarity index 77% rename from scripts/update-fonts-data-workflow.js rename to scripts/automated-update-workflow.js index 7547025c4ebfc..74fce1357c47f 100644 --- a/scripts/update-fonts-data-workflow.js +++ b/scripts/automated-update-workflow.js @@ -4,18 +4,28 @@ const { exec: execOriginal } = require('child_process') const exec = promisify(execOriginal) -const GITHUB_TOKEN = process.env.GITHUB_TOKEN || '' +const { + GITHUB_TOKEN = '', + SCRIPT = '', + BRANCH_NAME = 'unknown', + PR_TITLE = 'Automated update', + PR_BODY = '', +} = process.env if (!GITHUB_TOKEN) { console.log('missing GITHUB_TOKEN env') process.exit(1) } +if (!SCRIPT) { + console.log('missing SCRIPT env') + process.exit(1) +} async function main() { const octokit = new Octokit({ auth: GITHUB_TOKEN }) - const branchName = `update/fonts-data-${Date.now()}` + const branchName = `update/${BRANCH_NAME}-${Date.now()}` - await exec(`node scripts/update-google-fonts.js`) + await exec(`node ${SCRIPT}`) await exec(`git config user.name "vercel-release-bot"`) await exec(`git config user.email "infra+release@vercel.com"`) @@ -52,14 +62,14 @@ async function main() { repo, head: branchName, base: 'canary', - title: `Update font data`, - body: `This auto-generated PR updates font data with latest available`, + title: PR_TITLE, + body: PR_BODY, }) console.log('Created pull request', pullRequest.url) - const previousPullRequests = pullRequests.filter(({ title }) => { - return title.startsWith('Update font data') + const previousPullRequests = pullRequests.filter(({ title, user }) => { + return title.includes(PR_TITLE) && user.login === 'vercel-release-bot' }) if (previousPullRequests.length) {