Skip to content

Commit

Permalink
fix(preview release): revert workflow file in favor of updating it in…
Browse files Browse the repository at this point in the history
… a separate pr
  • Loading branch information
ByronDWall committed Jan 15, 2025
1 parent d17ef56 commit a793ef2
Showing 1 changed file with 16 additions and 26 deletions.
42 changes: 16 additions & 26 deletions .github/workflows/preview-release.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
name: Preview Release on Comment
name: Preview release

on:
push:
branches:
- 'preview/**'

permissions:
id-token: write
contents: read
pull-requests: write
issues: write

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)
Expand All @@ -26,29 +21,23 @@ jobs:
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: Validate branch name
run: |
if [[ ! "$BRANCH_NAME" =~ ^preview/[a-zA-Z0-9_-]+$ ]]; then
echo "Ignoring PR because of the branch name. Exiting workflow."
exit 1
fi
env:
BRANCH_NAME: ${{ steps.comment-branch.outputs.head_ref }}

- name: Checkout code
uses: actions/checkout@v4
with:
# Pass a personal access token (using our `ct-release-bot` account) to be able to trigger
# other workflows
# https://help.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token
# https://github.community/t/action-does-not-trigger-another-on-push-tag-action/17148/8
ref: ${{ steps.comment-branch.outputs.head_ref }}
token: ${{ steps.generate_github_token.outputs.token }}

- name: Validate branch name
run: |
BRANCH_NAME=$(echo "${GITHUB_REF#refs/heads/}" | tr '/' '-')
if [[ ! "$BRANCH_NAME" =~ ^preview/[a-zA-Z0-9_-]+$ ]]; then
echo "Ignoring PR because of the branch name. Exiting workflow."
exit 1
fi
- name: Setup Node (uses version in .nvmrc)
uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -95,10 +84,11 @@ jobs:

# Publish preview releases only if the branch starts with "preview/" and the commit message contains "[publish_preview]"
- name: Publishing preview releases to npm registry
if: startsWith(github.ref, 'refs/heads/preview/') && contains(github.event.head_commit.message, '[publish_preview]')
run: |
BRANCH_NAME=$(echo "${GITHUB_REF#refs/heads/}" | tr '/' '-')
git checkout ${{ github.head_ref }}
yarn changeset version --snapshot ${BRANCH_NAME}
yarn changeset publish --tag ${BRANCH_NAME}
env:
GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }}
GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }}

0 comments on commit a793ef2

Please sign in to comment.