chore: update workflow to trigger on push temporarily #2
Workflow file for this run
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: Preview Release | |
permissions: | |
contents: read | |
pull-requests: write | |
issues: write | |
statuses: write | |
# This is temporary for testing purposes | |
on: [push] | |
# on: | |
# issue_comment: | |
# types: [created] | |
jobs: | |
release: | |
# if: github.event.issue.pull_request && startsWith(github.event.comment.body, '[preview_deployment]') | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
steps: | |
# Get GitHub token via the CT Changesets App | |
- name: Generate GitHub token (via CT Changesets App) | |
id: generate_github_token | |
uses: tibdex/[email protected] | |
with: | |
app_id: ${{ secrets.CT_CHANGESETS_APP_ID }} | |
private_key: ${{ secrets.CT_CHANGESETS_APP_PEM }} | |
- name: Get branch of PR | |
uses: xt0rted/pull-request-comment-branch@v1 | |
id: comment-branch | |
- name: Set latest commit status as pending | |
uses: myrotvorets/set-commit-status-action@master | |
with: | |
sha: ${{ steps.comment-branch.outputs.head_sha }} | |
token: ${{ steps.generate_github_token.outputs.token }} | |
status: pending | |
- name: Checkout PR branch | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ steps.comment-branch.outputs.head_ref }} | |
token: ${{ steps.generate_github_token.outputs.token }} | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
registry-url: https://registry.npmjs.org/ | |
scope: "@commercetools" | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Installing dependencies and building packages | |
uses: ./.github/actions/ci | |
- name: Configure prerelease mode | |
run: | | |
git checkout ${{ steps.comment-branch.outputs.head_ref }} | |
pnpm changeset pre enter preview | |
env: | |
GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }} | |
- name: Verson package in prerelease mode | |
run: | | |
pnpm changeset version | |
env: | |
GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }} | |
- name: Publish prerelease packages to npm | |
run: | | |
pnpm changeset publish --tag preview | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Exit prerelease mode | |
run: | | |
pnpm changeset pre exit | |
env: | |
GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }} | |
- name: Post workflow result on PR as a comment | |
uses: actions/github-script@v6 | |
if: always() | |
with: | |
script: | | |
const name = '${{ github.workflow }}'; | |
const url = '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'; | |
const success = '${{ job.status }}' === 'success'; | |
const body = `Release workflow ${success ? 'succeeded ✅' : 'failed ❌'}\nSee details: ${url}`; | |
await github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: body | |
}); | |
- name: Set latest commit status as ${{ job.status }} | |
uses: myrotvorets/set-commit-status-action@master | |
if: always() | |
with: | |
sha: ${{ steps.comment-branch.outputs.head_sha }} | |
token: ${{ steps.generate_github_token.outputs.token }} | |
status: ${{ job.status }} |