Holiday Snow: allow usage on p2s as well #27700
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Calypso Live | |
on: | |
pull_request: | |
types: ['opened'] | |
jobs: | |
calypso-live: | |
name: 'Links to a calypso.live instance for your branch' | |
runs-on: ubuntu-latest | |
# We only offer the Calypso.live link to PRs created from the Automattic organization. | |
if: github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name | |
timeout-minutes: 10 | |
steps: | |
- name: Check if comment exists | |
id: has_comment | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
result-encoding: string | |
script: | | |
const comments = await github.rest.issues.listComments( { | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
} ); | |
// For debugging, if needed! | |
console.log( comments ); | |
const existingComment = comments.data.find( comment => comment.body.includes( "calypso-live-watermark:apr@v1" ) ); | |
const hasComment = existingComment ? "true" : "false"; | |
console.log( `Has existing comment: ${ hasComment }` ); | |
return hasComment; | |
- name: Build calypso.live link. | |
run: | | |
echo "LINK=https://calypso.live?image=registry.a8c.com/calypso/app:commit-${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT | |
echo "QR_CALYPSO=https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=https%3A%2F%2Fcalypso.live%3Fimage%3Dregistry.a8c.com%2Fcalypso%2Fapp%3Acommit-${{ github.event.pull_request.head.sha }}%26flags%3Doauth&choe=UTF-8" >> $GITHUB_OUTPUT | |
echo "QR_JETPACK=https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=https%3A%2F%2Fcalypso.live%3Fimage%3Dregistry.a8c.com%2Fcalypso%2Fapp%3Acommit-${{ github.event.pull_request.head.sha }}%26env%3Djetpack%26flags%3Doauth&choe=UTF-}" >> $GITHUB_OUTPUT | |
echo "QR_A4A=https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=https%3A%2F%2Fcalypso.live%3Fimage%3Dregistry.a8c.com%2Fcalypso%2Fapp%3Acommit-${{ github.event.pull_request.head.sha }}%26env%a8c-for-agencies%26flags%3Doauth&choe=UTF-}" >> $GITHUB_OUTPUT | |
id: build_link | |
- name: Post comment on PR | |
uses: actions/github-script@v6 | |
if: steps.has_comment.outputs.result == 'false' | |
with: | |
# Skip adding a comment if we already have one. | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: '<!--calypso-live-watermark:apr@v1--><details> <summary>Calypso Live <a href="${{steps.build_link.outputs.LINK}}">(direct link)</a></summary> <table> <tr> <td> <img src="${{steps.build_link.outputs.QR_CALYPSO}}"/> </td><td> <a href="${{steps.build_link.outputs.LINK}}">${{steps.build_link.outputs.LINK}}</a> </td></tr></table> </details> <details> <summary>Jetpack Cloud live <a href="${{steps.build_link.outputs.LINK}}&env=jetpack">(direct link)</a></summary> <table> <tr> <td> <img src="${{steps.build_link.outputs.QR_JETPACK}}"/> </td><td> <a href="${{steps.build_link.outputs.LINK}}&env=jetpack">${{steps.build_link.outputs.LINK}}&env=jetpack</a> </td></tr></table> </details> <details> <summary>Automattic for Agencies live <a href="${{steps.build_link.outputs.LINK}}&env=a8c-for-agencies">(direct link)</a></summary> <table> <tr> <td> <img src="${{steps.build_link.outputs.QR_A4A}}"/> </td><td> <a href="${{steps.build_link.outputs.LINK}}&env=a8c-for-agencies">${{steps.build_link.outputs.LINK}}&env=a8c-for-agencies</a> </td></tr></table> </details>' | |
}) |