|
| 1 | +name: Playroom |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - "**" |
| 10 | + |
| 11 | +env: # Set environment variables for every job and step in this workflow |
| 12 | + CLICOLOR: "1" # Enable colors for *NIX commands |
| 13 | + PY_COLORS: "1" # Enable colors for Python-based utilities |
| 14 | + FORCE_COLOR: "1" # Force colors in the terminal |
| 15 | + |
| 16 | +jobs: |
| 17 | + deploy: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + permissions: |
| 20 | + pull-requests: write # for dependabot |
| 21 | + contents: write # for deploying to GitHub Pages on master |
| 22 | + steps: |
| 23 | + - name: Checkout |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Node |
| 27 | + uses: ./.github/actions/node |
| 28 | + |
| 29 | + - name: Compile design tokens |
| 30 | + run: yarn tokens build |
| 31 | + |
| 32 | + - name: Build tailwind |
| 33 | + run: yarn tailwind-preset build |
| 34 | + |
| 35 | + - name: Build components |
| 36 | + run: yarn components build |
| 37 | + |
| 38 | + - name: Build Playroom |
| 39 | + run: yarn components build:playroom |
| 40 | + |
| 41 | + - name: Get BRANCH_URL |
| 42 | + # do not run on master branch |
| 43 | + if: github.ref != 'refs/heads/master' |
| 44 | + env: |
| 45 | + BRANCH_NAME: ${{ github.head_ref }} |
| 46 | + run: echo "BRANCH_URL=$(sed -e 's/[^a-zA-Z0-9]/-/g' <<< ${BRANCH_NAME})" >> $GITHUB_ENV |
| 47 | + |
| 48 | + - name: Get DOMAIN |
| 49 | + if: github.ref != 'refs/heads/master' |
| 50 | + run: echo "DOMAIN=https://kiwicom-orbit-playroom-${BRANCH_URL}.surge.sh" >> $GITHUB_ENV |
| 51 | + |
| 52 | + - name: Deploy to staging |
| 53 | + if: github.ref != 'refs/heads/master' |
| 54 | + run: yarn components deploy:surge ${DOMAIN} --token ${{ secrets.SURGE_TOKEN }} |
| 55 | + |
| 56 | + - name: Add comment to PR |
| 57 | + if: github.ref != 'refs/heads/master' |
| 58 | + uses: actions/github-script@v6 |
| 59 | + with: |
| 60 | + script: | |
| 61 | + const commentBody = `Playroom staging is available at ${process.env.DOMAIN}`; |
| 62 | +
|
| 63 | + const commentsList = await github.rest.issues.listComments({ |
| 64 | + issue_number: context.issue.number, |
| 65 | + owner: context.repo.owner, |
| 66 | + repo: context.repo.repo, |
| 67 | + }); |
| 68 | +
|
| 69 | + const comment = commentsList.data.find((comment) => comment.body.includes(commentBody)); |
| 70 | +
|
| 71 | + if (!comment) { |
| 72 | + github.rest.issues.createComment({ |
| 73 | + issue_number: context.issue.number, |
| 74 | + owner: context.repo.owner, |
| 75 | + repo: context.repo.repo, |
| 76 | + body: commentBody, |
| 77 | + }) |
| 78 | + } else { |
| 79 | + github.rest.issues.updateComment({ |
| 80 | + comment_id: comment.id, |
| 81 | + owner: context.repo.owner, |
| 82 | + repo: context.repo.repo, |
| 83 | + body: commentBody, |
| 84 | + }) |
| 85 | + } |
| 86 | +
|
| 87 | + # - name: Deploy to production |
| 88 | + # # run on master branch |
| 89 | + # if: github.ref == 'refs/heads/master' |
| 90 | + # run: yarn components deploy:playroom --ci |
| 91 | + # env: |
| 92 | + # GH_TOKEN: ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} |
0 commit comments