Skip to content

Commit

Permalink
Update Commit Preview action to use reusable build and publish jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
Southpaw1496 committed Aug 31, 2024
1 parent d5fc841 commit a2f1bf9
Showing 1 changed file with 22 additions and 68 deletions.
90 changes: 22 additions & 68 deletions .github/workflows/commit-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,25 @@ on: [push]
name: Commit preview

jobs:
generate-preview:
name: Generate commit preview
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
env:
GITHUB_PUBLISH_TOKEN: ${{ secrets.COZY_PAT }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
filter: 'blob:none'

- name: Setup PNPM and install dependencies
uses: pnpm/action-setup@v4
with:
version: latest
run_install: |
- args: [--frozen-lockfile]
- name: Build the project
run: pnpm run build

- name: Upload HTML artifact
uses: actions/upload-artifact@v4
with:
name: website-html
path: dist
retention-days: 1

- name: Upload Functions artifact
uses: actions/upload-artifact@v4
with:
name: website-functions
path: functions
retention-days: 1

- name: Upload package artifact
uses: actions/upload-artifact@v4
with:
name: website-package
path: |
package.json
package-lock.json
retention-days: 1

- name: Publish to Pages
if: env.CLOUDFLARE_API_TOKEN != '' && env.CLOUDFLARE_ACCOUNT_ID != ''
uses: cloudflare/pages-action@v1
id: publish
with:
apiToken: ${{ env.CLOUDFLARE_API_TOKEN }}
accountId: ${{ env.CLOUDFLARE_ACCOUNT_ID }}
projectName: quiltmc-org
directory: dist

- name: Add a comment on the commit
if: env.GITHUB_PUBLISH_TOKEN != ''
uses: peter-evans/commit-comment@5a6f8285b8f2e8376e41fe1b563db48e6cf78c09 # v3.0.0
with:
token: ${{ env.GITHUB_PUBLISH_TOKEN }}
repository: ${{ github.repository }}
sha: ${{ github.sha }}
body: "See preview on Cloudflare Pages: ${{ steps.publish.outputs.url }}"
build-website:
uses: ./.github/workflows/build-website.yml

publish:
uses: ./.github/workflows/publish.yml
needs: build-website

comment-on-commit:
name: Add a comment on the commit
runs-on: ubuntu-latest
needs: build-website
permissions:
contents: read
steps:
- name: Comment on the Comment
if: env.GITHUB_PUBLISH_TOKEN != ''
uses: peter-evans/commit-comment@5a6f8285b8f2e8376e41fe1b563db48e6cf78c09 # v3.0.0
with:
token: ${{ env.GITHUB_PUBLISH_TOKEN }}
repository: ${{ github.repository }}
sha: ${{ github.sha }}
body: "See preview on Cloudflare Pages: ${{ needs.publish.output.deployment-url }}"

0 comments on commit a2f1bf9

Please sign in to comment.