Skip to content

Commit

Permalink
ci: workflow file
Browse files Browse the repository at this point in the history
  • Loading branch information
danielleroux committed Mar 20, 2024
1 parent 040da89 commit 673002b
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 59 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/deploy-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Deploy Preview

on:
pull_request:
branches-ignore:
- changeset-release/main
types:
- opened
- reopened
- synchronize
- labeled

concurrency: pr-${{ github.ref }}

jobs:
deploy-preview:
if: ${{ contains(github.event.pull_request.labels.*.name, 'Deploy Preview') }}
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: ./.github/workflows/actions/turbo

# - name: Build
# run: pnpm build --cache-dir=.turbo --filter documentation

- name: Publish
id: publish
uses: netlify/actions/cli@master
with:
args: deploy --build --context deploy-preview --filter documentation
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}

- name: Find comments
id: find_comments
uses: actions-cool/issues-helper@v3
with:
actions: 'find-comments'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
comment-auth: 'github-actions[bot]'
body-includes: '🚢 PR Deployment is ready'

- uses: actions/github-script@v7
id: filter-comment
env:
COMMENTS_RESULT: ${{ steps.find_comments.outputs.comments }}
with:
script: |
const { COMMENTS_RESULT } = process.env;
const comments = JSON.parse(COMMENTS_RESULT);
if (comments.length === 1) {
return comments[0].id;
}
return '';
result-encoding: string

- name: Create PR comment
if: ${{ steps.filter-comment.outputs.result == '' }}
uses: actions-cool/issues-helper@v3
with:
issue-number: ${{ github.event.pull_request.number }}
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
body: |
🚢 PR Deployment is ready
Preview ✅: [${{ steps.publish.outputs.NETLIFY_URL }}](${{ steps.publish.outputs.NETLIFY_URL }})
Logs: [${{ steps.publish.outputs.NETLIFY_LOGS_URL }}](${{ steps.publish.outputs.NETLIFY_LOGS_URL }})
59 changes: 0 additions & 59 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,62 +139,3 @@ jobs:

- name: Test
run: pnpm run test --cache-dir=.turbo --filter !\documentation


deploy-preview:
if: ${{ contains(github.event.pull_request.labels.*.name, 'Deploy Preview') }}
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: ./.github/workflows/actions/turbo

# - name: Build
# run: pnpm build --cache-dir=.turbo --filter documentation

- name: Publish
id: publish
uses: netlify/actions/cli@master
with:
args: deploy --build --context deploy-preview --filter documentation
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}

- name: Find comments
id: find_comments
uses: actions-cool/issues-helper@v3
with:
actions: 'find-comments'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
comment-auth: 'github-actions[bot]'
body-includes: '🚢 PR Deployment is ready'

- uses: actions/github-script@v7
id: filter-comment
env:
COMMENTS_RESULT: ${{ steps.find_comments.outputs.comments }}
with:
script: |
const { COMMENTS_RESULT } = process.env;
const comments = JSON.parse(COMMENTS_RESULT);
if (comments.length === 1) {
return comments[0].id;
}
return '';
result-encoding: string

- name: Create PR comment
if: ${{ steps.filter-comment.outputs.result == '' }}
uses: actions-cool/issues-helper@v3
with:
issue-number: ${{ github.event.pull_request.number }}
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
body: |
🚢 PR Deployment is ready
Preview ✅: [${{ steps.publish.outputs.NETLIFY_URL }}](${{ steps.publish.outputs.NETLIFY_URL }})
Logs: [${{ steps.publish.outputs.NETLIFY_LOGS_URL }}](${{ steps.publish.outputs.NETLIFY_LOGS_URL }})

0 comments on commit 673002b

Please sign in to comment.