From 738564400af4bb02ab42c696bd2db14d16b43cf5 Mon Sep 17 00:00:00 2001 From: Sarka Chwastkova Date: Wed, 15 Jan 2025 11:56:13 +0100 Subject: [PATCH] chore: add Playroom deployment --- .github/workflows/delete-tests-reports.yml | 2 + .github/workflows/playroom.yml | 92 ++++++++++++++++++++++ packages/orbit-components/.gitignore | 1 + packages/orbit-components/package.json | 2 + 4 files changed, 97 insertions(+) create mode 100644 .github/workflows/playroom.yml diff --git a/.github/workflows/delete-tests-reports.yml b/.github/workflows/delete-tests-reports.yml index 60b3acb5ed..f59ca45dc8 100644 --- a/.github/workflows/delete-tests-reports.yml +++ b/.github/workflows/delete-tests-reports.yml @@ -18,9 +18,11 @@ jobs: uses: ./.github/actions/node - name: Delete Report + # yarn surge teardown $DOMAIN_PLAYROOM --token ${{ secrets.SURGE_TOKEN }} run: | echo "Deleting report for branch $BRANCH_NAME" BRANCH_URL=$(echo ${BRANCH_NAME} | sed -e 's/[^a-zA-Z0-9]/-/g') DOMAIN=https://kiwicom-orbit-test-report-${BRANCH_URL}.surge.sh + DOMAIN_PLAYROOM=https://kiwicom-orbit-test-report-${BRANCH_URL}-playroom.surge.sh yarn surge teardown $DOMAIN --token ${{ secrets.SURGE_TOKEN }} continue-on-error: true diff --git a/.github/workflows/playroom.yml b/.github/workflows/playroom.yml new file mode 100644 index 0000000000..a7896d6785 --- /dev/null +++ b/.github/workflows/playroom.yml @@ -0,0 +1,92 @@ +name: Playroom + +on: + push: + branches: + - master + pull_request: + branches: + - "**" + +env: # Set environment variables for every job and step in this workflow + CLICOLOR: "1" # Enable colors for *NIX commands + PY_COLORS: "1" # Enable colors for Python-based utilities + FORCE_COLOR: "1" # Force colors in the terminal + +jobs: + deploy: + runs-on: ubuntu-latest + permissions: + pull-requests: write # for dependabot + contents: write # for deploying to GitHub Pages on master + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Node + uses: ./.github/actions/node + + - name: Compile design tokens + run: yarn tokens build + + - name: Build tailwind + run: yarn tailwind-preset build + + - name: Build components + run: yarn components build + + - name: Build Playroom + run: yarn components build:playroom + + - name: Get BRANCH_URL + # do not run on master branch + if: github.ref != 'refs/heads/master' + env: + BRANCH_NAME: ${{ github.head_ref }} + run: echo "BRANCH_URL=$(sed -e 's/[^a-zA-Z0-9]/-/g' <<< ${BRANCH_NAME})" >> $GITHUB_ENV + + - name: Get DOMAIN + if: github.ref != 'refs/heads/master' + run: echo "DOMAIN=https://kiwicom-orbit-playroom-${BRANCH_URL}.surge.sh" >> $GITHUB_ENV + + - name: Deploy to staging + if: github.ref != 'refs/heads/master' + run: yarn components deploy:surge ${DOMAIN} --token ${{ secrets.SURGE_TOKEN }} + + - name: Add comment to PR + if: github.ref != 'refs/heads/master' + uses: actions/github-script@v6 + with: + script: | + const commentBody = `Playroom staging is available at ${process.env.DOMAIN}`; + + const commentsList = await github.rest.issues.listComments({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + }); + + const comment = commentsList.data.find((comment) => comment.body.includes(commentBody)); + + if (!comment) { + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: commentBody, + }) + } else { + github.rest.issues.updateComment({ + comment_id: comment.id, + owner: context.repo.owner, + repo: context.repo.repo, + body: commentBody, + }) + } + + # - name: Deploy to production + # # run on master branch + # if: github.ref == 'refs/heads/master' + # run: yarn components deploy:playroom --ci + # env: + # GH_TOKEN: ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} diff --git a/packages/orbit-components/.gitignore b/packages/orbit-components/.gitignore index a2d0c4b3d1..2d9873ad68 100644 --- a/packages/orbit-components/.gitignore +++ b/packages/orbit-components/.gitignore @@ -5,6 +5,7 @@ .out .cache .DS_STORE +.playroom/ src/data/airportIllustrations.json src/data/illustrations.json src/data/icons.json diff --git a/packages/orbit-components/package.json b/packages/orbit-components/package.json index 30948bff8b..daf0ee88a2 100644 --- a/packages/orbit-components/package.json +++ b/packages/orbit-components/package.json @@ -28,9 +28,11 @@ "build:iconsFont": "node --loader ts-node/esm config/createSVGFont.mts", "build:emailIcons": "yarn build:icons && yarn build:iconsFont && node --loader ts-node/esm config/generateEmailIcons.mts", "build:storybook": "yarn build:icons && storybook build -c .storybook -o .out", + "build:playroom": "playroom build", "eslint:check": "eslint . --report-unused-disable-directives", "test-ct": "playwright test -c playwright-ct.config.ts", "deploy:storybook": "yarn storybook-to-ghpages -e ./.out", + "deploy:playroom": "yarn surge .playroom/", "deploy:surge": "yarn surge .out/", "docs-gen": "monstra docs" },