Continuous Integration (PR opened) #4000
This file contains hidden or 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: Continuous Integration (PR opened) | |
| on: | |
| workflow_run: | |
| workflows: ['Continuous Integration'] | |
| types: | |
| - completed | |
| jobs: | |
| download-artifact: | |
| name: Download artifact | |
| if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }} | |
| runs-on: ubuntu-latest | |
| outputs: | |
| pr-number: ${{ steps.set-pr-number.outputs.pr-number }} | |
| steps: | |
| - id: set-pr-number | |
| uses: actions/github-script@v7.0.1 | |
| with: | |
| script: | | |
| var artifacts = await github.actions.listWorkflowRunArtifacts({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| run_id: ${{ github.event.workflow_run.id }}, | |
| }); | |
| var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | |
| return /^storybooks-/.test(artifact.name); | |
| })[0]; | |
| var download = await github.actions.downloadArtifact({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| artifact_id: matchArtifact.id, | |
| archive_format: 'zip', | |
| }); | |
| var fs = require('fs'); | |
| fs.writeFileSync('${{ github.workspace }}/storybooks.zip', Buffer.from(download.data)); | |
| const prNumber = /^storybooks-(\d+)$/.exec(matchArtifact.name)[1]; | |
| console.log(`::set-output name=pr-number::${ prNumber }`); | |
| - run: unzip storybooks.zip | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: storybooks | |
| path: | | |
| fuselage/storybook-static | |
| onboarding-ui/storybook-static | |
| layout/storybook-static | |
| publish-to-gh-pages: | |
| name: Publish to GitHub Pages | |
| needs: | |
| - download-artifact | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: 'https://rocketchat.github.io/fuselage/fuselage/${{ needs.download-artifact.outputs.pr-number }}' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: gh-pages | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: storybooks | |
| path: packages | |
| - run: | | |
| rm -rf "fuselage/${{ needs.download-artifact.outputs.pr-number }}" "layout/${{ needs.download-artifact.outputs.pr-number }}" "uikit-playground/${{ needs.download-artifact.outputs.pr-number }}" "onboarding-ui/${{ needs.download-artifact.outputs.pr-number }}" | |
| mv -v packages/fuselage/storybook-static "fuselage/${{ needs.download-artifact.outputs.pr-number }}" | |
| mv -v packages/onboarding-ui/storybook-static "onboarding-ui/${{ needs.download-artifact.outputs.pr-number }}" | |
| mv -v packages/layout/storybook-static "layout/${{ needs.download-artifact.outputs.pr-number }}" | |
| rm -rf packages | |
| - uses: crazy-max/ghaction-github-pages@v4 | |
| with: | |
| target_branch: gh-pages | |
| build_dir: . | |
| commit_message: 'Deploy to Github Pages [skip ci]' | |
| jekyll: false | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} |