From f50a5aa753c0ba31e9bc253625347e83c8b0e5d9 Mon Sep 17 00:00:00 2001 From: IkiWiki Date: Sun, 25 Aug 2024 21:18:33 -0400 Subject: [PATCH] forgejo-ci: generate GITHUB_PR_NAME with curl API request --- .forgejo/workflows/preview.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.forgejo/workflows/preview.yaml b/.forgejo/workflows/preview.yaml index 1f619bd..9d701a8 100644 --- a/.forgejo/workflows/preview.yaml +++ b/.forgejo/workflows/preview.yaml @@ -10,7 +10,8 @@ jobs: steps: - name: Environment setup run: | - apk add git ikiwiki po4a perl-yaml-tiny tree nodejs + apk add git ikiwiki po4a perl-yaml-tiny tree nodejs jq coreutils + echo "GITHUB_PR_NAME=$(curl -s https://ayakael.net/api/v1/repos/forge/ayakael.net/pulls/${{ github.ref_name }} | jq .title | tr ' ' '-' | tr -d ':')" >> $GITHUB_ENV - name: Repo pull uses: actions/checkout@v4 with: @@ -25,9 +26,9 @@ jobs: token: ${{ secrets.PAGES_TOKEN }} - name: Render website run: | - rm -rf public/previews/$CURRENT_CONTENT_PATH || true - mkdir -p public/previews/${{ github.ref_name }} - sed -i "s|destdir.*|destdir: ./public/previews/${{ github.ref_name }}|" ikiwiki.setup + rm -rf public/previews/$GITHUB_PR_NAME || true + mkdir -p public/previews/$GITHUB_PR_NAME + sed -i "s|destdir.*|destdir: ./public/previews/$GITHUB_PR_NAME|" ikiwiki.setup ikiwiki --setup ikiwiki.setup cd public/previews tree -d -H '.' -L 1 --noreport --charset utf-8 -T "Versions" -o index.html @@ -38,7 +39,7 @@ jobs: cp .forgejo/workflows/deploy.yaml public/.forgejo/workflows/. git log -1 --pretty=%B > commit.txt cd public - date > previews/${{ github.ref_name}}/generated.txt + date > previews/$GITHUB_PR_NAME/generated.txt # Note: the following account information will not work on GHES git config user.name "forgejo-actions[bot]" git config user.email "dev@ayakael.net"