Skip to content

Commit

Permalink
Updated workflows and created shell script to delete all artifacts fr…
Browse files Browse the repository at this point in the history
…om the repo
  • Loading branch information
atteggiani committed Nov 8, 2023
1 parent e4e3038 commit f870c58
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 30 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/create_pr_preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ jobs:
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

Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/delete_all_artifacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
#
# !! CAUTION WHEN YOU USE THIS SCRIPT !!
# 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
4 changes: 1 addition & 3 deletions .github/workflows/deploy_development_website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,4 @@ jobs:
folder: website
target-folder: ${{ env.TARGET_FOLDER }}
commit-message: Deploy development website. 🛫
force: false

# - name: Deploy to Github pages
force: false
24 changes: 1 addition & 23 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,4 @@ jobs:
branch: ${{ env.TARGET_BRANCH }}
clean-exclude: |
pr-preview/
development_website/
# deploy:
# needs: build
# environment:
# name: github-pages
# url: ${{ steps.deployment.outputs.page_url }}
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# with:
# ref: 'gh-pages'
# - name: Setup Pages
# uses: actions/configure-pages@v3
# - name: Upload artifact
# uses: actions/upload-pages-artifact@v2
# with:
# # Upload entire repository
# path: '.'
# - name: Deploy to GitHub Pages
# id: deployment
# uses: actions/deploy-pages@v2
development_website/
2 changes: 0 additions & 2 deletions .github/workflows/remove_pr_preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ jobs:
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

Expand Down

0 comments on commit f870c58

Please sign in to comment.