Skip to content

Commit

Permalink
Refactor GHA workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 committed Jan 12, 2025
1 parent a72479b commit 4b3c683
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 101 deletions.
98 changes: 49 additions & 49 deletions .github/workflows/add_mod_port.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,59 +38,59 @@ jobs:
runs-on: ubuntu-latest
steps:

- name: Echo distinct ID ${{ github.event.inputs.distinct_id }}
run: echo ${{ github.event.inputs.distinct_id }}
- name: Echo distinct ID ${{ github.event.inputs.distinct_id }}
run: echo ${{ github.event.inputs.distinct_id }}

- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
cache-dependency-path: scripts/requirements.txt
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
cache-dependency-path: scripts/requirements.txt

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

- name: Run add_mod_port.py
run: |
python scripts/add_mod_port.py \
"${{ github.event.inputs.mod }}" \
"${{ github.event.inputs.modloader }}" \
"${{ github.event.inputs.mod_version }}" \
"${{ github.event.inputs.mc_version }}" \
${{ github.event.inputs.modloader == 'fabric' && format('--fapi_version {0}', github.event.inputs.fapi_version) || '' }} \
"${{ github.event.inputs.file_id }}"
- name: Run add_mod_port.py
run: |
python scripts/add_mod_port.py \
"${{ github.event.inputs.mod }}" \
"${{ github.event.inputs.modloader }}" \
"${{ github.event.inputs.mod_version }}" \
"${{ github.event.inputs.mc_version }}" \
${{ github.event.inputs.modloader == 'fabric' && format('--fapi_version {0}', github.event.inputs.fapi_version) || '' }} \
"${{ github.event.inputs.file_id }}"
- name: Commit changes
run: |
MOD="${{ github.event.inputs.mod }}"
MOD_VERSION="${{ github.event.inputs.mod_version }}"
MC_VERSION="${{ github.event.inputs.mc_version }}"
MODLOADER="${{ github.event.inputs.modloader }}"
git config --local user.email "[email protected]"
git config --local user.name "Wurst-Bot"
git add .
git commit -m "[Wurst-Bot] Port $MOD $MOD_VERSION to Minecraft $MC_VERSION ($MODLOADER)"
git push
- name: Commit changes
run: |
MOD="${{ github.event.inputs.mod }}"
MOD_VERSION="${{ github.event.inputs.mod_version }}"
MC_VERSION="${{ github.event.inputs.mc_version }}"
MODLOADER="${{ github.event.inputs.modloader }}"
git config --local user.email "[email protected]"
git config --local user.name "Wurst-Bot"
git add .
git commit -m "[Wurst-Bot] Port $MOD $MOD_VERSION to Minecraft $MC_VERSION ($MODLOADER)"
git push
- name: Trigger hugo workflow
id: hugo_dispatch
uses: codex-/return-dispatch@v2
with:
token: ${{ github.token }}
owner: Wurst-Imperium
repo: wimods.net
ref: master
workflow: hugo.yml
- name: Trigger hugo workflow
id: hugo_dispatch
uses: codex-/return-dispatch@v2
with:
token: ${{ github.token }}
owner: Wurst-Imperium
repo: wimods.net
ref: master
workflow: hugo.yml

- name: Wait for website update to finish (run ${{ steps.hugo_dispatch.outputs.run_id }})
uses: codex-/await-remote-run@v1
with:
token: ${{ github.token }}
owner: Wurst-Imperium
repo: wimods.net
run_id: ${{ steps.hugo_dispatch.outputs.run_id }}
run_timeout_seconds: 300 # 5 minutes
- name: Wait for hugo workflow to finish (run ${{ steps.hugo_dispatch.outputs.run_id }})
uses: codex-/await-remote-run@v1
with:
token: ${{ github.token }}
owner: Wurst-Imperium
repo: wimods.net
run_id: ${{ steps.hugo_dispatch.outputs.run_id }}
run_timeout_seconds: 300 # 5 minutes
44 changes: 23 additions & 21 deletions .github/workflows/announce_mod_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,30 @@ jobs:
runs-on: ubuntu-latest
steps:

- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
cache-dependency-path: scripts/requirements.txt
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
cache-dependency-path: scripts/requirements.txt

- name: Install dependencies
run: |
pip install -r scripts/requirements.txt
- name: Install dependencies
run: |
pip install -r scripts/requirements.txt
- name: Run announce_mod_update.py
id: announce
env:
WURSTFORUM_TOKEN: ${{ secrets.WF_BOT_TOKEN }}
run: |
python scripts/announce_mod_update.py "${{ github.event.inputs.mod }}" "${{ github.event.inputs.mod_version }}"
- name: Run announce_mod_update.py
id: announce
env:
WURSTFORUM_TOKEN: ${{ secrets.WF_BOT_TOKEN }}
run: |
python scripts/announce_mod_update.py \
"${{ github.event.inputs.mod }}" \
"${{ github.event.inputs.mod_version }}"
- name: Write summary
run: |
echo "Discussion ID: ${{ steps.announce.outputs.discussion_id }}" >> $GITHUB_STEP_SUMMARY
echo "Link: <https://wurstforum.net/d/${{ steps.announce.outputs.discussion_id }}>" >> $GITHUB_STEP_SUMMARY
- name: Write summary
run: |
echo "Discussion ID: ${{ steps.announce.outputs.discussion_id }}" >> $GITHUB_STEP_SUMMARY
echo "Link: <https://wurstforum.net/d/${{ steps.announce.outputs.discussion_id }}>" >> $GITHUB_STEP_SUMMARY
65 changes: 34 additions & 31 deletions .github/workflows/hugo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ name: Deploy Hugo site to Pages

on:
push:
branches: ["master"]
branches:
- "master"
tags-ignore:
- "**"
schedule:
# cron: minute, hour, day of month, month, day of week
# Update the copyright year on Jan 1st
Expand All @@ -25,48 +28,48 @@ concurrency:
cancel-in-progress: false

jobs:

# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Echo distinct ID ${{ github.event.inputs.distinct_id }}
run: echo ${{ github.event.inputs.distinct_id }}
- name: Checkout
uses: actions/checkout@v4
- name: Install Hugo CLI
run: |
HUGO_VERSION=$(curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | grep tag_name | cut -d '"' -f 4 | cut -c 2-)
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
- name: Echo distinct ID ${{ github.event.inputs.distinct_id }}
run: echo ${{ github.event.inputs.distinct_id }}
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Hugo CLI
run: |
HUGO_VERSION=$(curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest \
| grep tag_name | cut -d '"' -f 4 | cut -c 2-)
wget -O ${{ runner.temp }}/hugo.deb \
https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Build with Hugo
env:
HUGO_ENVIRONMENT: production
run: |
hugo \
--minify \
--baseURL "https://www.wimods.net/"
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: public/
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Build with Hugo
env:
HUGO_ENVIRONMENT: production
run: hugo --minify --baseURL "https://www.wimods.net/"
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: public/

# Deployment job
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- name: Purge Cloudflare cache
run: |
curl -X POST "https://api.cloudflare.com/client/v4/zones/${{ secrets.CLOUDFLARE_ZONE_ID }}/purge_cache" \
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- name: Purge Cloudflare cache
run: |
curl -X POST "https://api.cloudflare.com/client/v4/zones/${{ secrets.CLOUDFLARE_ZONE_ID }}/purge_cache" \
-H "Authorization: Bearer ${{ secrets.CLOUDFLARE_PURGE_TOKEN }}" \
-H "Content-Type: application/json" \
--data '{"purge_everything":true}'

0 comments on commit 4b3c683

Please sign in to comment.