Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Davide/test workflows #604

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/create_pr_preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Create PR preview

on:
pull_request:
types:
- opened
- reopened
- synchronize

concurrency:
group: preview-${{ github.ref }}
cancel-in-progress: true

env:
PR: ${{ github.event.number }}
TARGET_FOLDER: pr_preview/pr-${{ github.event.number }}
TARGET_BRANCH: gh-pages

jobs:
build-and-deploy-preview:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Python setup
uses: actions/setup-python@v4
with:
python-version: 3.x

- name: Install dependencies
run: pip install -r requirements.txt

- name: Build preview website
run: mkdocs build -f mkdocs.yml -d pr_preview

- name: Add preview on gh-pages branch
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: ${{ env.TARGET_BRANCH }}
folder: pr_preview
target-folder: ${{ env.TARGET_FOLDER }}
commit-message: Deploy preview for PR ${{ env.PR }} 🛫
force: false

# - name: Deploy to Github pages

- name: Get date
run: echo "DATE=$(date '+%Y-%m-%d %H:%M %Z')" >> $GITHUB_ENV

- name: Leave a comment after deployment
# if: env.deployment_status == 'success'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-preview
number: ${{ env.PR }}
message: "\
PR Preview

:---:

🛫 Deployed preview to
https://access-hive.org.au/pr_preview/pr-${{ env.PR }}

on branch [${{ env.TARGET_BRANCH }}]\
(${{ github.server_url }}/${{ github.repository }}/tree/${{ env.TARGET_BRANCH }}) \
- ${{ env.DATE }}
"
58 changes: 0 additions & 58 deletions .github/workflows/pr_preview.yml

This file was deleted.

65 changes: 65 additions & 0 deletions .github/workflows/remove_pr_preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Remove PR preview

on:
pull_request:
types:
- closed

concurrency:
group: preview-${{ github.ref }}
cancel-in-progress: true

env:
PR: ${{ github.event.number }}
TARGET_FOLDER: pr_preview/pr-${{ github.event.number }}
TARGET_BRANCH: gh-pages

jobs:
close-preview:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ env.TARGET_BRANCH }}

- name: Remove pr-preview
shell: bash
run: |
if [ ! -d ${{ env.TARGET_FOLDER }} ]
then
echo "Nothing to remove!"
exit 0
fi
rm -rf ${{ env.TARGET_FOLDER }}
echo "Removed pr preview for pr-${{ env.PR }}."

- name: Commit to gh-pages
shell: bash
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git add .
git commit -m "Deleted '${{ env.TARGET_FOLDER }}' folder."
git push origin ${{ env.TARGET_BRANCH }}

# - name: Deploy to Github-pages

- name: Get date
run: echo "DATE=$(date '+%Y-%m-%d %H:%M %Z')" >> $GITHUB_ENV

- name: Leave a comment after removal
# if: env.deployment_status == 'success'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-preview
number: ${{ github.event.number }}
message: "\
PR Preview

:---:

🛬 Preview removed because the pull request was closed.

${{ env.DATE }}
"