FEC 155 - Upgrade all UI Kit packages to React 19 #74
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 on Comment | |
permissions: | |
id-token: write | |
contents: read | |
pull-requests: write | |
issues: write | |
on: | |
issue_comment: | |
types: [created] | |
jobs: | |
release-preview-on-comment: | |
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/github-app-token@v2.1.0 | |
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: 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://git.luolix.topmunity/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: Setup Node (uses version in .nvmrc) | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
- name: Get yarn cache | |
id: yarn-cache | |
run: echo "::set-output name=dir::$(yarn config get cacheFolder)" | |
- uses: actions/cache@v4 | |
with: | |
path: ${{ steps.yarn-cache.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock', 'patches/*.patch') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Install dependencies | |
run: yarn install --immutable | |
- name: Creating .npmrc | |
run: | | |
cat << EOF > "$HOME/.npmrc" | |
provenance=true | |
email=npmjs@commercetools.com | |
//registry.npmjs.org/:_authToken=$NPM_TOKEN | |
EOF | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Building packages | |
run: yarn build | |
- name: Building package READMEs | |
run: yarn generate-readmes | |
env: | |
CI: true | |
# Publish preview releases only if the branch starts with "preview/" and the pr comment contains "[preview_deployment]" | |
- name: Publishing preview releases to npm registry | |
run: | | |
PREVIEW_TAG=$(echo "$BRANCH_NAME" | sed -e 's/^preview\///') | |
yarn changeset version --snapshot ${PREVIEW_TAG} | |
yarn changeset publish --tag ${PREVIEW_TAG} | |
env: | |
GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }} | |
BRANCH_NAME: ${{ steps.comment-branch.outputs.head_ref }} | |
- name: Post workflow result on PR as a comment | |
if: always() | |
run: | | |
gh issue comment ${{ github.event.issue.number }} \ | |
--body "Release workflow ${{ job.status == 'success' && 'succeeded β ' || 'failed β' }}\nSee details: [Workflow Run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" | |
env: | |
GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }} | |