|
| 1 | +name: Update ember-test-app on ember-cli minor release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + schedule: |
| 6 | + - cron: '0 9 * * 1' # weekly on Monday; job will self-gate to every 10 weeks |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + issues: write |
| 11 | + pull-requests: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + gate: |
| 15 | + name: Gate to every 10 weeks |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Check schedule |
| 19 | + run: | |
| 20 | + set -euo pipefail |
| 21 | + week=$(date +%V) |
| 22 | + if [ $((10#$week % 10)) -ne 0 ]; then |
| 23 | + echo "Skipping: ISO week $week is not a 10-week interval." |
| 24 | + exit 0 |
| 25 | + fi |
| 26 | +
|
| 27 | + update-app-template: |
| 28 | + name: Regenerate smoke-tests app template |
| 29 | + runs-on: ubuntu-latest |
| 30 | + needs: gate |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v4 |
| 33 | + - name: Setup Node.js |
| 34 | + uses: actions/setup-node@v4 |
| 35 | + with: |
| 36 | + node-version: 20 |
| 37 | + - name: Generate ember-test-app using classic blueprint |
| 38 | + run: | |
| 39 | + set -euo pipefail |
| 40 | + tmpdir=$(mktemp -d) |
| 41 | + echo "Using temp dir: $tmpdir" |
| 42 | + cd "$tmpdir" |
| 43 | + pnpm dlx ember-cli@latest new ember-test-app -b @ember-tooling/classic-build-app-blueprint --no-welcome --skip-git --skip-npm --ember-data=false |
| 44 | + node "$GITHUB_WORKSPACE/.github/scripts/update-smoke-test-template.mjs" \ |
| 45 | + "$tmpdir/ember-test-app" \ |
| 46 | + "$GITHUB_WORKSPACE/smoke-tests/app-template" |
| 47 | +
|
| 48 | + - name: Create PR |
| 49 | + uses: peter-evans/create-pull-request@v7 |
| 50 | + with: |
| 51 | + branch: smoke-tests/update-app-template |
| 52 | + delete-branch: false |
| 53 | + commit-message: "Update ember-test-app template" |
| 54 | + title: "Update ember-test-app template (ember-cli latest)" |
| 55 | + body: | |
| 56 | + Regenerated the smoke-tests app-template using ember-cli latest. |
| 57 | +
|
| 58 | + update-v2-app-template: |
| 59 | + name: Regenerate smoke-tests v2 app template |
| 60 | + runs-on: ubuntu-latest |
| 61 | + needs: gate |
| 62 | + steps: |
| 63 | + - uses: actions/checkout@v4 |
| 64 | + - name: Setup Node.js |
| 65 | + uses: actions/setup-node@v4 |
| 66 | + with: |
| 67 | + node-version: 20 |
| 68 | + - name: Generate v2-app-template |
| 69 | + run: | |
| 70 | + set -euo pipefail |
| 71 | + tmpdir=$(mktemp -d) |
| 72 | + echo "Using temp dir: $tmpdir" |
| 73 | + cd "$tmpdir" |
| 74 | + pnpm dlx ember-cli@latest new v2-app-template --no-welcome --skip-git --skip-npm --ember-data=false |
| 75 | + node "$GITHUB_WORKSPACE/.github/scripts/update-smoke-test-template.mjs" \ |
| 76 | + "$tmpdir/v2-app-template" \ |
| 77 | + "$GITHUB_WORKSPACE/smoke-tests/v2-app-template" |
| 78 | +
|
| 79 | + - name: Create PR |
| 80 | + uses: peter-evans/create-pull-request@v7 |
| 81 | + with: |
| 82 | + branch: smoke-tests/update-v2-app-template |
| 83 | + delete-branch: false |
| 84 | + commit-message: "Update v2-app-template" |
| 85 | + title: "Update v2-app-template (ember-cli latest)" |
| 86 | + body: | |
| 87 | + Regenerated the smoke-tests v2-app-template using ember-cli latest. |
| 88 | +
|
| 89 | + report-failure: |
| 90 | + name: Report failure |
| 91 | + runs-on: ubuntu-latest |
| 92 | + needs: |
| 93 | + - update-app-template |
| 94 | + - update-v2-app-template |
| 95 | + if: failure() |
| 96 | + steps: |
| 97 | + - name: Create issue |
| 98 | + uses: actions/github-script@v7 |
| 99 | + with: |
| 100 | + script: | |
| 101 | + const title = "Smoke-test app template update failed"; |
| 102 | + const body = [ |
| 103 | + "The scheduled smoke-test app template update workflow failed.", |
| 104 | + "", |
| 105 | + `Run: ${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`, |
| 106 | + "", |
| 107 | + `Attempt: ${process.env.GITHUB_RUN_ATTEMPT}` |
| 108 | + ].join("\\n"); |
| 109 | +
|
| 110 | + const { data: existing } = await github.rest.search.issuesAndPullRequests({ |
| 111 | + q: `repo:${context.repo.owner}/${context.repo.repo} is:issue is:open in:title "${title}"` |
| 112 | + }); |
| 113 | +
|
| 114 | + if (existing.items.length > 0) { |
| 115 | + core.info(`Existing issue found: #${existing.items[0].number}`); |
| 116 | + return; |
| 117 | + } |
| 118 | +
|
| 119 | + const { data: issue } = await github.rest.issues.create({ |
| 120 | + owner: context.repo.owner, |
| 121 | + repo: context.repo.repo, |
| 122 | + title, |
| 123 | + body, |
| 124 | + assignees: ["kategengler"] |
| 125 | + }); |
| 126 | +
|
| 127 | + core.info(`Created issue #${issue.number}`); |
0 commit comments