release: june 2024 #130
Workflow file for this run
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: Deploy Example Previews | |
on: | |
issue_comment: | |
types: [created] | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
- reopened | |
- labeled | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
inputs: | |
example_name: | |
description: "Example name to deploy preview" | |
type: choice | |
required: true | |
options: | |
- finefoods-antd | |
- finefoods-client | |
- finefoods-material-ui | |
- app-crm | |
- pixels | |
- invoicer | |
jobs: | |
changes: | |
runs-on: ubuntu-latest | |
# Required permissions | |
permissions: | |
pull-requests: read | |
# Set job outputs to values from filter step | |
outputs: | |
examples: ${{ steps.filter.outputs.changes }} | |
all_examples: ${{ steps.deploy-previews-label.outputs.all_examples || false }} | |
dispatch_example: ${{ join(inputs.example_name) || false }} | |
steps: | |
- name: Get PR labels | |
id: pr-labels | |
uses: joerick/[email protected] | |
# For pull requests it's not necessary to checkout the code | |
- name: 'Check deploy previews label' | |
id: deploy-previews-label | |
run: echo 'all_examples=["finefoods-antd", "finefoods-client", "finefoods-material-ui", "app-crm", "pixels", "invoicer"]' >> $GITHUB_OUTPUT | |
if: ${{ contains(steps.pr-labels.outputs.labels, ' deploy-previews ') }} | |
- uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
filters: | | |
'finefoods-antd': 'examples/finefoods-antd/**' | |
'finefoods-client': 'examples/finefoods-client/**' | |
'finefoods-material-ui': 'examples/finefoods-material-ui/**' | |
'app-crm': 'examples/app-crm/**' | |
'pixels': 'examples/pixels/**' | |
'invoicer': 'examples/invoicer/**' | |
build_previews_matrix: | |
name: Build previews matrix | |
permissions: | |
pull-requests: read | |
issues: read | |
outputs: | |
matrix: ${{ steps.build_examples_matrix.outputs.EXAMPLES }} | |
runs-on: ubuntu-latest | |
if: ${{ contains(github.event.comment.body, '/deploy') }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build examples matrix | |
id: build_examples_matrix | |
run: COMMENT_BODY=${{ github.event.comment.body }} node ./.github/workflows/scripts/deploy-previews.js | |
deploy_example_preview: | |
needs: build_previews_matrix | |
if: needs.build_previews_matrix.outputs.matrix != '[]' | |
permissions: | |
pull-requests: read | |
issues: read | |
strategy: | |
matrix: | |
example: ${{ fromJson(needs.build_previews_matrix.outputs.matrix) }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v3 | |
with: | |
version: 9 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
cache: "pnpm" | |
- name: Install Dependencies | |
run: pnpm install --ignore-scripts | |
- name: Build example | |
run: pnpm build --scope ${{ matrix.example.name }} | |
- name: Deploy to Netlify | |
uses: nwtgck/[email protected] | |
with: | |
publish-dir: ${{ matrix.example.publish_dir }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
deploy-message: "Deploy from GitHub Actions [Comment]" | |
alias: deploy-preview-${{ matrix.example.name }}-${{ github.event.comment.node_id }} | |
enable-pull-request-comment: true | |
overwrites-pull-request-comment: true | |
github-deployment-environment: "deploy-preview-${{ matrix.example.name }}-${{ github.event.comment.node_id }}" | |
netlify-config-path: ${{ matrix.example.netlify_config_path }} | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
timeout-minutes: 10 | |
preview: | |
runs-on: ubuntu-latest | |
needs: changes | |
if: ${{ needs.changes.outputs.all_examples || needs.changes.outputs.examples != '[]' || needs.changes.outputs.dispatch_example }} | |
strategy: | |
fail-fast: false | |
max-parallel: 6 | |
matrix: | |
example: ${{ fromJSON(needs.changes.outputs.examples || needs.changes.outputs.all_examples || needs.changes.outputs.dispatch_example) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v3 | |
with: | |
version: 9 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
cache: "pnpm" | |
- name: Install Dependencies | |
run: pnpm install --ignore-scripts | |
- name: Build example | |
run: pnpm build --scope ${{ matrix.example }} | |
- name: Deploy to Netlify | |
uses: nwtgck/[email protected] | |
with: | |
publish-dir: ${{ format('./examples/{0}/{1}', matrix.example, contains(fromJson('["finefoods-client"]'), matrix.example) && '.next' || 'dist') }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
deploy-message: "Deploy from GitHub Actions" | |
alias: deploy-preview-${{ matrix.example }}-${{ github.event.number }} | |
enable-pull-request-comment: false | |
overwrites-pull-request-comment: false | |
github-deployment-environment: "deploy-preview-${{ matrix.example }}-${{ github.event.number }}" | |
netlify-config-path: ./examples/${{ matrix.example }}/netlify.toml | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
timeout-minutes: 10 |