Skip to content

Commit

Permalink
Merge pull request #605 from ACCESS-Hive/development
Browse files Browse the repository at this point in the history
Merging after sprint meeting
  • Loading branch information
atteggiani authored Nov 15, 2023
2 parents 2faf115 + 6e0377a commit f260031
Show file tree
Hide file tree
Showing 42 changed files with 254 additions and 503 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/delete_all_artifacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
#
# This script deletes all artifacts from the repo using Github CLI.
# This will NOT break the deployment of ACCESS-Hive (https://access-hive.org.au/)

set -eu

invoke_api() {
gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" "$@"
}

list_artifacts() {
invoke_api https://api.github.com/repos/ACCESS-Hive/access-hive.github.io/actions/artifacts
}

list=$(list_artifacts | jq '.artifacts | .[] | .url')
tot=$(list_artifacts | jq '.total_count')

delete_artifact() {
invoke_api -X DELETE "$1"
echo "Deleted artifact $2/$tot: $1" 1>&2
}

i=1
while true; do
if [ "$i" -lt "$tot" ]; then
for l in ${list} ; do
artifact=$(echo $l | tr -d '"')
delete_artifact "$artifact" $i $tot
i=$((i+1))
done
list=$(list_artifacts | jq '.artifacts | .[] | .url')
else
echo "Done!"
exit 0
fi
done
181 changes: 181 additions & 0 deletions .github/workflows/deploy_to_github_pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
name: Deploy to GitHub Pages
on:
push: #Action fires anytime there is a push to the following branches
branches:
- main
- development
pull_request: #Action also fires anytime a PR is (re)opened, closed or synchronized
types:
- opened
- reopened
- synchronize
- closed

jobs:
pr-preview-setup:
# If the action is fired because of a PR, and the PR is not from the development branch, run this job
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref != 'development' }}
runs-on: ubuntu-latest
steps:
- name: Get date
run: echo "DATE=$(date '+%Y-%m-%d %H:%M %Z')" >> $GITHUB_ENV

- name: Setup pr-preview
# If the PR is new (or has been reopened), setup the message that will
# get updated with the URL after deployment
if: ${{ github.event.action == 'opened' || github.event.action == 'reopened' }}
uses: thollander/[email protected]
with:
comment_tag: pr-preview
pr_number: ${{ github.event.number }}
message: "\
PR Preview
:---:
🛫 Deployment still ongoing.<br>
Preview URL will be available at the end of the deployment.
For more information, please check the [Actions](https://github.com/ACCESS-Hive/access-hive.github.io/actions) tab.
${{ env.DATE }}
"

# If the PR is closed, remove the pr-preview URL
- name: Remove pr-preview URL
if: ${{github.event.action == 'closed'}}
uses: thollander/[email protected]
with:
comment_tag: pr-preview
pr_number: ${{ github.event.number }}
message: "\
PR Preview
:---:
🛬 Preview removed because the pull request was closed.
${{ env.DATE }}
"

build:
# Cancel any previous build/deploy jobs that are still running (no need to build/deploy multiple times)
concurrency:
group: build-deploy
cancel-in-progress: true
runs-on: ubuntu-latest
outputs:
pr_nums: ${{ steps.build.outputs.pr_nums }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: main

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

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

# Build full website using main, development and open PRs head branches
# (excluding `development` and `main` as PR head branches)
- name: Build full website
id: build
shell: bash
run: |
retry() {
command="$1"
n_tries="$2"
wait="$3"
exit_msg="$4"
eval "$command"
until [ $? == 0 ]; do
if [ $i -eq $((n_tries - 1)) ]; then
echo "$exit_msg"
exit 1
else
((i++))
fi
sleep $wait
eval "$command"
done
}
git fetch --all
echo "Build main website"
retry 'mkdocs build -f mkdocs.yml -d ../website' 5 1 "Failed to build main website."
echo "Build development website"
retry 'git checkout development' 5 1 "Failed to checkout development branch."
retry 'mkdocs build -f mkdocs.yml -d ../website/development-website' 5 1 "Failed to build development website."
echo "Build PR websites"
command="pr_list=\$(curl -s https://api.github.com/repos/ACCESS-Hive/access-hive.github.io/pulls?state=opened \
| jq '.[] | select(.head.label!=\"ACCESS-Hive:development\" and .head.label!=\"ACCESS-Hive:main\")')"
retry "$command" 5 1 "Failed to fetch opened PRs."
pr_nums=($(jq '.number' <<< $pr_list))
if [[ -n $pr_nums ]]; then
echo "Found PR numbers: $(sed 's/\s/, /g' <<< ${pr_nums[@]})."
pr_sha=($(jq '.head.sha' <<< $pr_list))
echo "pr_nums=$(sed 's/\s/,/g' <<< [${pr_nums[@]}])" >> "$GITHUB_OUTPUT"
for i in ${!pr_nums[@]}; do
retry "git checkout ${pr_sha[i]}" 5 1 "Failed to checkout git hash ${pr_sha[i]}."
retry "mkdocs build -f mkdocs.yml -d ../website/pr-preview/pr-${pr_nums[i]}" 5 1 "Failed to build pr-${pr_nums[i]} website."
done
else
echo "No open PR found."
fi
echo "Give the right file permissions"
chmod -c -R +rX ../website
- name: Create artifact for deployment to GitHub Pages
uses: actions/upload-pages-artifact@v2
with:
path: ../website

deploy:
needs: build
runs-on: ubuntu-latest
# Cancel any previous build/deploy jobs that are still running (no need to build/deploy multiple times)
concurrency:
group: build-deploy
cancel-in-progress: true
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

steps:
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v2

# Set pr-preview URL
pr-preview:
needs: [build,deploy]
# If there are open PRs (whose head branch is neither `development` nor `main`), run this job
if: ${{ needs.build.outputs.pr_nums }}
runs-on: ubuntu-latest
# Run the same job for each of the open PRs found
strategy:
matrix:
pr_nums: ${{fromJson(needs.build.outputs.pr_nums)}}
steps:
- name: Get date
run: echo "DATE=$(date '+%Y-%m-%d %H:%M %Z')" >> $GITHUB_ENV

- name: Set pr-preview URL
if: ${{github.event.action != 'closed'}}
uses: thollander/[email protected]
with:
comment_tag: pr-preview
pr_number: ${{ matrix.pr_nums }}
message: "\
PR Preview
:---:
🚀 Deployed preview to
https://access-hive.org.au/pr-preview/pr-${{ matrix.pr_nums }}
${{ env.DATE }}
"
58 changes: 0 additions & 58 deletions .github/workflows/pr_preview.yml

This file was deleted.

62 changes: 0 additions & 62 deletions .github/workflows/publish.yml

This file was deleted.

2 changes: 0 additions & 2 deletions docs/call_contribute.md

This file was deleted.

33 changes: 0 additions & 33 deletions docs/community_resources/computing_on_gadi.md

This file was deleted.

Loading

0 comments on commit f260031

Please sign in to comment.