Skip to content

611f3f57423121ab790bd9f317968335858952a9 #200

611f3f57423121ab790bd9f317968335858952a9

611f3f57423121ab790bd9f317968335858952a9 #200

Workflow file for this run

name: Deploy
on:
push:
branches:
- deploy
jobs:
clean:
name: Clean up
if: |
github.event.head_commit.message != 'chore: cleaned up orphaned deployments'
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- name: Remove PRs
run: |
pr_ids=$(gh api --header 'Accept: application/vnd.github+json' --method GET /repos/${{ github.repository }}/pulls | jq -r '. | map(.number) | join("\\|")')
find pr -type d -mindepth 1 -maxdepth 1 -not -regex "^pr\/\(${pr_ids}\)" -exec rm -rf {} + || true
env:
GH_TOKEN: ${{ github.token }}
- name: Remove releases
run: |
released_versions=$(gh api --header 'Accept: application/vnd.github+json' --method GET /repos/${{ github.repository }}/releases | jq -r '. + [{"tag_name": "latest"}, {"tag_name": "pr"}] | map(.tag_name | sub("\\.";"\\.";"g")) | join("\\|")')
find . -not -path '*/.*' -type d -mindepth 1 -maxdepth 1 -not -regex "^\.\/\(${released_versions}\)" -exec rm -rf {} + || true
env:
GH_TOKEN: ${{ github.token }}
- id: status
run: |
if [ -z "$(git status --porcelain)" ]; then
echo "Working tree clean"
echo "changes=false" >> $GITHUB_OUTPUT
else
echo "Working tree dirty"
echo "changes=true" >> $GITHUB_OUTPUT
fi
- name: Apply changes
if: ${{ steps.status.outputs.changes == 'true' }}
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add .
git commit -m "chore: cleaned up orphaned deployments"
git push origin
env:
GH_TOKEN: ${{ github.token }}
deploy:
name: Deploy
needs: clean
runs-on: ubuntu-latest
environment:
name: Pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
contents: read
pages: write
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/configure-pages@v3
- name: Upload
uses: actions/upload-pages-artifact@v1
with:
path: "."
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1