Rewrite example release workflow to the proven subpath-safe pattern
CI / build-and-smoke (push) Successful in 4s
CI / build-and-smoke (push) Successful in 4s
Manual clone + docker build + docker cp instead of actions/checkout and 'uses:' (both broken by the /git subpath). Pins packager @v1.
This commit is contained in:
+39
-26
@@ -3,11 +3,15 @@
|
|||||||
# and attaches it to a matching Gitea release.
|
# and attaches it to a matching Gitea release.
|
||||||
#
|
#
|
||||||
# Requires: Actions enabled on the repo, and a runner advertising `ubuntu-latest`
|
# Requires: Actions enabled on the repo, and a runner advertising `ubuntu-latest`
|
||||||
# (or change runs-on to a label your act_runner registers).
|
# with Docker available.
|
||||||
#
|
#
|
||||||
# NOTE: octowow.st is served under the /git subpath. act_runner reports
|
# NOTE on octowow.st: the instance is served under the /git subpath, but Gitea
|
||||||
# GITHUB_SERVER_URL without it, breaking checkout and the release API calls, so
|
# generates URLs without it, which breaks actions/checkout and `uses:` action
|
||||||
# we pin GITHUB_SERVER_URL below. Drop this once the server's ROOT_URL is fixed.
|
# resolution. So this workflow avoids both: it clones manually against the
|
||||||
|
# correct base and runs the packager via `docker build` + `docker cp` (bind
|
||||||
|
# mounts don't work either — the inner docker uses the host daemon). Once the
|
||||||
|
# server's ROOT_URL is fixed, this can be simplified to actions/checkout +
|
||||||
|
# `uses: paste/mpq-packager@v1`.
|
||||||
|
|
||||||
name: Release MPQ
|
name: Release MPQ
|
||||||
on:
|
on:
|
||||||
@@ -18,39 +22,48 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
package:
|
package:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
|
||||||
GITHUB_SERVER_URL: https://octowow.st/git
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout (manual; instance under /git)
|
||||||
uses: actions/checkout@v4
|
run: |
|
||||||
|
git init -q .
|
||||||
|
git remote add origin "https://gitea:${{ secrets.GITHUB_TOKEN }}@octowow.st/git/${{ github.repository }}.git"
|
||||||
|
git fetch -q --depth 1 origin "${{ github.ref }}"
|
||||||
|
git checkout -q FETCH_HEAD
|
||||||
|
|
||||||
|
- name: Build packager image
|
||||||
|
run: |
|
||||||
|
git clone -q --depth 1 --branch v1 \
|
||||||
|
"https://gitea:${{ secrets.GITHUB_TOKEN }}@octowow.st/git/paste/mpq-packager.git" /tmp/packager
|
||||||
|
docker build -q -t mpq-packager /tmp/packager
|
||||||
|
|
||||||
- name: Build patch MPQ
|
- name: Build patch MPQ
|
||||||
id: pack
|
run: |
|
||||||
uses: paste/mpq-packager@v1
|
set -euo pipefail
|
||||||
with:
|
cid=$(docker create \
|
||||||
manifest: mpq.yaml
|
-e INPUT_MANIFEST=mpq.yaml \
|
||||||
version: ${{ github.ref_name }}
|
-e INPUT_VERSION=${{ github.ref_name }} \
|
||||||
|
-e INPUT_OUT_DIR=/work/dist \
|
||||||
|
-e GITHUB_WORKSPACE=/work \
|
||||||
|
mpq-packager)
|
||||||
|
docker cp . "$cid:/work"
|
||||||
|
docker start -a "$cid"
|
||||||
|
docker cp "$cid:/work/dist/patch-Z.mpq" ./patch-Z.mpq
|
||||||
|
docker rm "$cid" >/dev/null
|
||||||
|
ls -l patch-Z.mpq
|
||||||
|
|
||||||
- name: Create release and upload asset
|
- name: Create release and upload asset
|
||||||
env:
|
env:
|
||||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
|
API="https://octowow.st/git/api/v1/repos/${{ github.repository }}"
|
||||||
TAG="${GITHUB_REF_NAME}"
|
TAG="${{ github.ref_name }}"
|
||||||
MPQ="${{ steps.pack.outputs.mpq-path }}"
|
|
||||||
NAME="${{ steps.pack.outputs.mpq-name }}"
|
|
||||||
|
|
||||||
echo "Creating release $TAG"
|
|
||||||
RID=$(curl -fsSL -X POST "$API/releases" \
|
RID=$(curl -fsSL -X POST "$API/releases" \
|
||||||
-H "Authorization: token $TOKEN" \
|
-H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"draft\":false,\"prerelease\":false}" \
|
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"draft\":false,\"prerelease\":false}" \
|
||||||
| python3 -c 'import sys,json;print(json.load(sys.stdin)["id"])')
|
| python3 -c 'import sys,json;print(json.load(sys.stdin)["id"])')
|
||||||
|
curl -fsSL -X POST "$API/releases/$RID/assets?name=patch-Z.mpq" \
|
||||||
echo "Uploading $NAME to release $RID"
|
|
||||||
curl -fsSL -X POST "$API/releases/$RID/assets?name=$NAME" \
|
|
||||||
-H "Authorization: token $TOKEN" \
|
-H "Authorization: token $TOKEN" \
|
||||||
-H "Content-Type: application/octet-stream" \
|
-H "Content-Type: application/octet-stream" \
|
||||||
--data-binary "@$MPQ"
|
--data-binary "@patch-Z.mpq"
|
||||||
echo "Done."
|
echo "Released $TAG with patch-Z.mpq"
|
||||||
|
|||||||
Reference in New Issue
Block a user