From ea5ea7fedbddeea675fb58e4752137889d318772 Mon Sep 17 00:00:00 2001 From: George Gastaldi Date: Wed, 27 Mar 2024 12:03:55 -0300 Subject: [PATCH] Revert "Support preview from forked repositories 15" This reverts commit 6275bcb64ee3e7ac8d1635c0fb80a4e745ffb8da. Revert "Support preview from forked repositories 14" This reverts commit e52cb3839ff2ac23f66df770e74badbf0a6877af. Revert "Support preview from forked repositories 13" This reverts commit b14ad1651e49e3592cae4fe3cf6a59e16d1cb049. Revert "Support preview from forked repositories 12 - Merge workflows" This reverts commit fcdbe32321f43379e813dfe7bb85dc636ca3283e. --- .github/workflows/preview.yml | 64 +++++++++++++++++++++++++++++++++++ .github/workflows/publish.yml | 56 ------------------------------ 2 files changed, 64 insertions(+), 56 deletions(-) create mode 100644 .github/workflows/preview.yml diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml new file mode 100644 index 0000000000..c79d5ab318 --- /dev/null +++ b/.github/workflows/preview.yml @@ -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=$(> $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 + + body-include: '' + 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. + + + body-include: '' + number: ${{ steps.pr.outputs.id }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 943baa5f1e..d2e37a86fd 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -9,9 +9,6 @@ on: pull_request: types: [ opened, synchronize, reopened ] -env: - SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} - defaults: run: shell: bash @@ -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 @@ -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=$(> $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 - - body-include: '' - 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. - - - body-include: '' - 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')"