Skip to content

Commit

Permalink
Revert "Support preview from forked repositories 15"
Browse files Browse the repository at this point in the history
This reverts commit 6275bcb.

Revert "Support preview from forked repositories 14"

This reverts commit e52cb38.

Revert "Support preview from forked repositories 13"

This reverts commit b14ad16.

Revert "Support preview from forked repositories 12 - Merge workflows"

This reverts commit fcdbe32.
  • Loading branch information
gastaldi committed Mar 27, 2024
1 parent 6275bcb commit ea5ea7f
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 56 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Surge.sh Preview

on:
workflow_run:
workflows: [ "Publish website" ]
types:
- completed

defaults:
run:
shell: bash

jobs:
preview:
runs-on: ubuntu-latest
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
permissions:
pull-requests: write # Required to update PR status comment
steps:
- name: Download PR Artifact
uses: actions/download-artifact@v4
with:
name: site
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}

- name: Download PR ID Artifact
uses: actions/download-artifact@v4
with:
name: pr-id
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}

- name: Store PR id as variable
id: pr
run: |
echo "id=$(<pr-id.txt)" >> $GITHUB_OUTPUT
rm -f pr-id.txt
- name: Publishing to surge for preview
id: deploy
run: npx surge ./ --domain https://quarkiverse-docs-pr-${{ steps.pr.outputs.id }}-preview.surge.sh --token ${{ secrets.SURGE_TOKEN }}

- name: Update PR status comment on success
uses: actions-cool/maintain-one-comment@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: |
🚀 PR Preview ${{ github.sha }} has been successfully built and deployed to https://quarkiverse-docs-pr-${{ steps.pr.outputs.id }}-preview.surge.sh
<!-- Sticky Pull Request Comment -->
body-include: '<!-- Sticky Pull Request Comment -->'
number: ${{ steps.pr.outputs.id }}

- name: Update PR status comment on failure
if: ${{ failure() }}
uses: actions-cool/maintain-one-comment@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: |
😭 Deploy PR Preview failed.
<img width="300" src="https://user-images.githubusercontent.com/507615/90250824-4e066700-de6f-11ea-8230-600ecc3d6a6b.png">
<!-- Sticky Pull Request Comment -->
body-include: '<!-- Sticky Pull Request Comment -->'
number: ${{ steps.pr.outputs.id }}
56 changes: 0 additions & 56 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ on:
pull_request:
types: [ opened, synchronize, reopened ]

env:
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}

defaults:
run:
shell: bash
Expand Down Expand Up @@ -39,14 +36,12 @@ jobs:
run: npm run build

- name: Store PR id
if: github.event_name == 'pull_request'
run: |
mkdir pr
echo ${{ github.event.number }} > ./pr/pr-id.txt
- name: Upload PR id as artifact
uses: actions/upload-artifact@v4
if: github.event_name == 'pull_request'
with:
name: pr-id
path: pr
Expand All @@ -59,57 +54,6 @@ jobs:
path: build/site
retention-days: 1

preview:
runs-on: ubuntu-latest
needs: [ build ]
if: github.event_name == 'pull_request'
permissions:
pull-requests: write # Required to update PR status comment
steps:
- name: Download PR Artifact
uses: actions/download-artifact@v4
with:
name: site
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Download PR ID Artifact
uses: actions/download-artifact@v4
with:
name: pr-id
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Store PR id as variable
id: pr
run: |
echo "id=$(<pr-id.txt)" >> $GITHUB_OUTPUT
rm -f pr-id.txt
- name: Publishing to surge for preview
id: deploy
run: npx surge ./ --domain https://quarkiverse-docs-pr-${{ steps.pr.outputs.id }}-preview.surge.sh --token $SURGE_TOKEN

- name: Update PR status comment on success
uses: actions-cool/maintain-one-comment@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: |
🚀 PR Preview ${{ github.sha }} has been successfully built and deployed to https://quarkiverse-docs-pr-${{ steps.pr.outputs.id }}-preview.surge.sh
<!-- Sticky Pull Request Comment -->
body-include: '<!-- Sticky Pull Request Comment -->'
number: ${{ steps.pr.outputs.id }}

- name: Update PR status comment on failure
if: ${{ failure() }}
uses: actions-cool/maintain-one-comment@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: |
😭 Deploy PR Preview failed.
<img width="300" src="https://user-images.githubusercontent.com/507615/90250824-4e066700-de6f-11ea-8230-600ecc3d6a6b.png">
<!-- Sticky Pull Request Comment -->
body-include: '<!-- Sticky Pull Request Comment -->'
number: ${{ steps.pr.outputs.id }}

deploy:
# Only try and deploy on merged code
if: "github.repository == 'quarkiverse/quarkiverse-docs' && github.ref_name == 'main' && (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')"
Expand Down

0 comments on commit ea5ea7f

Please sign in to comment.