antifreeze #132
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Avoid SNAPSHOT being frozen by jitpack | |
name: antifreeze | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push or pull request events but only for the "main" branch | |
schedule: | |
- cron: "5 3 */2 * *" | |
workflow_dispatch: | |
inputs: | |
update-snapshot-tag: | |
description: "Should the snapshot tag be reset" | |
default: false | |
required: false | |
type: boolean | |
workflow_call: | |
inputs: | |
update-snapshot-tag: | |
default: false | |
required: false | |
type: boolean | |
env: | |
GH_BOT_EMAIL: "41898282+github-actions[bot]@users.noreply.github.com" | |
GH_BOT_NAME: "GitHub Action" | |
jobs: | |
clear: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: yq - portable yaml processor | |
uses: mikefarah/[email protected] | |
- name: Update snapshot tag | |
if: inputs.update-snapshot-tag == true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
shell: bash | |
run: | | |
SNAPSHOT=$(yq '.release.snapshot-version' .github/project.yml) | |
git config user.name ${{ env.GH_BOT_NAME }} | |
git config user.email ${{ env.GH_BOT_EMAIL }} | |
echo "Update tag for $SNAPSHOT" | |
git push origin :refs/tags/$SNAPSHOT | |
git tag -f $SNAPSHOT | |
git push --tags | |
- name: Delete Jitpack resource | |
id: jitpack-antifreeze | |
env: | |
JITPACK_TOKEN: ${{ secrets.JITPACK_TOKEN }} | |
shell: bash | |
run: | | |
SNAPSHOT=$(yq '.release.snapshot-version' .github/project.yml) | |
ARTIFACT=$(yq '.jitpack.artifact' .github/project.yml) | |
GROUP=$(yq '.jitpack.group' .github/project.yml) | |
ARTIFACT_URL=https://jitpack.io/api/builds/$GROUP/$ARTIFACT | |
echo | |
echo $ARTIFACT_URL | |
echo | |
curl ${ARTIFACT_URL} | |
echo | |
echo "Delete JitPack artifacts for tag: ${ARTIFACT_URL}/$SNAPSHOT" | |
curl -X "DELETE" -u${JITPACK_TOKEN} ${ARTIFACT_URL}/$SNAPSHOT | |
echo | |
curl ${ARTIFACT_URL} |