|
1 | | -name: Canary Release |
2 | | - |
3 | | -on: |
4 | | - pull_request: |
5 | | - types: [opened, synchronize, reopened] |
6 | | - branches: [main, next] |
7 | | - |
8 | | -permissions: |
9 | | - contents: write |
10 | | - pull-requests: write |
11 | | - packages: write |
12 | | - |
13 | | -env: |
14 | | - DOTNET_VERSION: "10.0.*" |
15 | | - |
16 | | -concurrency: |
17 | | - group: canary-${{ github.event.pull_request.number }} |
18 | | - cancel-in-progress: true |
19 | | - |
20 | | -jobs: |
21 | | - canary: |
22 | | - name: Create Canary Release |
23 | | - runs-on: ubuntu-latest |
24 | | - if: github.event_name == 'pull_request' && (github.event.head_commit == null || (!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci'))) |
25 | | - outputs: |
26 | | - canary-version: ${{ steps.canary.outputs.newVersion }} |
27 | | - published: ${{ steps.canary.outputs.published }} |
28 | | - steps: |
29 | | - - name: Generate GitHub App Token |
30 | | - id: generate-token |
31 | | - uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v2.0.0 |
32 | | - with: |
33 | | - app-id: ${{ vars.AUTO_RELEASE_APP_ID }} |
34 | | - private-key: ${{ secrets.AUTO_RELEASE_APP_PRIVATE_KEY }} |
35 | | - |
36 | | - - name: Checkout |
37 | | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
38 | | - with: |
39 | | - fetch-depth: 0 |
40 | | - token: ${{ steps.generate-token.outputs.token }} |
41 | | - |
42 | | - - name: Setup Auto |
43 | | - uses: auto-it/setup-auto@8088350955c4009f66570db1f401fa1e0adb5a38 # v2.0.0 |
44 | | - |
45 | | - - name: Create Canary Release |
46 | | - id: canary |
47 | | - run: | |
48 | | - auto canary --pr ${{ github.event.pull_request.number }} --quiet > /tmp/canary-output.txt || echo "published=false" >> $GITHUB_OUTPUT |
49 | | - |
50 | | - if grep -q "Published" /tmp/canary-output.txt; then |
51 | | - echo "published=true" >> $GITHUB_OUTPUT |
52 | | - VERSION=$(cat /tmp/canary-output.txt | grep -oP 'v\K[0-9]+\.[0-9]+\.[0-9]+-canary\.[0-9]+\.[a-f0-9]+' || echo "") |
53 | | - echo "newVersion=${VERSION}" >> $GITHUB_OUTPUT |
54 | | - echo "Canary version: ${VERSION}" |
55 | | - else |
56 | | - echo "published=false" >> $GITHUB_OUTPUT |
57 | | - fi |
58 | | - env: |
59 | | - GH_TOKEN: ${{ steps.generate-token.outputs.token }} |
60 | | - |
61 | | - - name: Comment on PR |
62 | | - if: steps.canary.outputs.published == 'true' |
63 | | - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 |
64 | | - with: |
65 | | - github-token: ${{ steps.generate-token.outputs.token }} |
66 | | - script: | |
67 | | - const version = '${{ steps.canary.outputs.newVersion }}'; |
68 | | - const body = `## Canary Release Published |
69 | | - |
70 | | - **Version:** \`v${version}\` |
71 | | - |
72 | | - This PR has been published as a canary release. Docker images will be built with this version tag. |
73 | | - |
74 | | - ### Testing |
75 | | - You can test this canary by pulling: |
76 | | - \`\`\`bash |
77 | | - docker pull ghcr.io/${{ github.repository }}/catalog:v${version} |
78 | | - \`\`\` |
79 | | - `; |
80 | | - |
81 | | - github.rest.issues.createComment({ |
82 | | - issue_number: context.issue.number, |
83 | | - owner: context.repo.owner, |
84 | | - repo: context.repo.repo, |
85 | | - body: body |
86 | | - }); |
| 1 | +name: Canary Release |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, synchronize, reopened] |
| 6 | + branches: [main, next] |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + pull-requests: write |
| 11 | + packages: write |
| 12 | + |
| 13 | +env: |
| 14 | + DOTNET_VERSION: "10.0.*" |
| 15 | + |
| 16 | +concurrency: |
| 17 | + group: canary-${{ github.event.pull_request.number }} |
| 18 | + cancel-in-progress: true |
| 19 | + |
| 20 | +jobs: |
| 21 | + canary: |
| 22 | + name: Create Canary Release |
| 23 | + runs-on: ubuntu-latest |
| 24 | + if: github.event_name == 'pull_request' && (github.event.head_commit == null || (!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci'))) |
| 25 | + outputs: |
| 26 | + canary-version: ${{ steps.canary.outputs.newVersion }} |
| 27 | + published: ${{ steps.canary.outputs.published }} |
| 28 | + steps: |
| 29 | + - name: Generate GitHub App Token |
| 30 | + id: generate-token |
| 31 | + uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v2.0.0 |
| 32 | + with: |
| 33 | + app-id: ${{ vars.AUTO_RELEASE_APP_ID }} |
| 34 | + private-key: ${{ secrets.AUTO_RELEASE_APP_PRIVATE_KEY }} |
| 35 | + |
| 36 | + - name: Checkout |
| 37 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 38 | + with: |
| 39 | + fetch-depth: 0 |
| 40 | + token: ${{ steps.generate-token.outputs.token }} |
| 41 | + |
| 42 | + - name: Setup Auto |
| 43 | + uses: auto-it/setup-auto@8088350955c4009f66570db1f401fa1e0adb5a38 # v2.0.0 |
| 44 | + |
| 45 | + - name: Create Canary Release |
| 46 | + id: canary |
| 47 | + run: | |
| 48 | + auto canary --pr ${{ github.event.pull_request.number }} --quiet > /tmp/canary-output.txt || echo "published=false" >> $GITHUB_OUTPUT |
| 49 | + |
| 50 | + if grep -q "Published" /tmp/canary-output.txt; then |
| 51 | + echo "published=true" >> $GITHUB_OUTPUT |
| 52 | + VERSION=$(cat /tmp/canary-output.txt | grep -oP 'v\K[0-9]+\.[0-9]+\.[0-9]+-canary\.[0-9]+\.[a-f0-9]+' || echo "") |
| 53 | + echo "newVersion=${VERSION}" >> $GITHUB_OUTPUT |
| 54 | + echo "Canary version: ${VERSION}" |
| 55 | + else |
| 56 | + echo "published=false" >> $GITHUB_OUTPUT |
| 57 | + fi |
| 58 | + env: |
| 59 | + GH_TOKEN: ${{ steps.generate-token.outputs.token }} |
| 60 | + |
| 61 | + - name: Comment on PR |
| 62 | + if: steps.canary.outputs.published == 'true' |
| 63 | + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 |
| 64 | + with: |
| 65 | + github-token: ${{ steps.generate-token.outputs.token }} |
| 66 | + script: | |
| 67 | + const version = '${{ steps.canary.outputs.newVersion }}'; |
| 68 | + const body = `## Canary Release Published |
| 69 | + |
| 70 | + **Version:** \`v${version}\` |
| 71 | + |
| 72 | + This PR has been published as a canary release. Docker images will be built with this version tag. |
| 73 | + |
| 74 | + ### Testing |
| 75 | + You can test this canary by pulling: |
| 76 | + \`\`\`bash |
| 77 | + docker pull ghcr.io/${{ github.repository }}/catalog:v${version} |
| 78 | + \`\`\` |
| 79 | + `; |
| 80 | + |
| 81 | + github.rest.issues.createComment({ |
| 82 | + issue_number: context.issue.number, |
| 83 | + owner: context.repo.owner, |
| 84 | + repo: context.repo.repo, |
| 85 | + body: body |
| 86 | + }); |
0 commit comments