Skip to content

Update MC versions (2024-11-06) #27

Update MC versions (2024-11-06)

Update MC versions (2024-11-06) #27

Workflow file for this run

name: Deploy to production
on:
push:
branches:
- 'master'
paths:
- '.github/workflows/deploy.yml'
- 'version/**'
workflow_dispatch:
# we don't need GITHUB_TOKEN in this workflow
permissions: {}
jobs:
deploy:
name: Deploy to mirror
runs-on: self-hosted
environment: technic-mirror
steps:
- name: Pull changes
run: cd $MIRROR_BASEPATH && sudo -u $MIRROR_USER2 -H git pull
env:
MIRROR_BASEPATH: ${{ secrets.MIRROR_BASEPATH }}
MIRROR_USER2: ${{ secrets.MIRROR_USER2 }}
- name: Detect new MC versions
run: |
# abort on errors
set -euo pipefail
cd $MIRROR_BASEPATH
NEW_VERSION_PATHS="$(sudo -u $MIRROR_USER2 -H git diff --name-only --diff-filter=A "$GITHUB_REF_NAME@{1}".."$GITHUB_REF_NAME" -- version/)"
if [ -n "$NEW_VERSION_PATHS" ]; then
payload=$(printf '%s' "$NEW_VERSION_PATHS" | cut -d'/' -f2 | sort -V | \
jq --raw-input --slurp 'split("\n") | map(select(. != "")) | unique | join(", ") | "New MC versions: " + . | {content: .}')
printf 'Payload:\n%s\n' "$payload"
curl -X POST --fail-with-body --silent --show-error \
"${DISCORD_WEBHOOK_URL}?wait=true" \
-H 'Content-Type: application/json' \
-d "$payload"
fi
env:
MIRROR_BASEPATH: ${{ secrets.MIRROR_BASEPATH }}
MIRROR_USER2: ${{ secrets.MIRROR_USER2 }}
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}