From 5fe2d0a78bc75a3e160548c2072b631bbf7574c7 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Fri, 23 Aug 2024 00:12:33 -0400 Subject: [PATCH] forgejo-ci: deploy to $branch-testing when PR is a WIP --- .forgejo/bin/deploy.sh | 8 ++++++++ .forgejo/workflows/build-aarch64.yaml | 7 ++++++- .forgejo/workflows/build-x86_64.yaml | 8 +++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.forgejo/bin/deploy.sh b/.forgejo/bin/deploy.sh index 3138b69..3a4fb0a 100755 --- a/.forgejo/bin/deploy.sh +++ b/.forgejo/bin/deploy.sh @@ -14,6 +14,14 @@ for apk in $apkgs; do arch=$(echo $apk | awk -F '/' '{print $3}') name=$(echo $apk | awk -F '/' '{print $4}') + if [ "$(curl -s $GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/pulls/$GITHUB_EVENT_NUMBER | jq .draft)" == "true" ]; then + # if draft, send to -testing branch + branch="$branch-testing" + else + # if not draft, assume that this was sent to $branch-testing and nuke it + curl -s --user $FORGE_REPO_USER:$FORGE_REPO_TOKEN -X DELETE $TARGET_REPO/$BASEBRANCH/$branch-testing/$arch/$name + fi + echo "Sending $name of arch $arch to $TARGET_REPO/$BASEBRANCH/$branch" return=$(curl -s --user $FORGE_REPO_USER:$FORGE_REPO_TOKEN --upload-file $apk $TARGET_REPO/$BASEBRANCH/$branch 2>&1) echo $return diff --git a/.forgejo/workflows/build-aarch64.yaml b/.forgejo/workflows/build-aarch64.yaml index d6738b2..429ed0b 100644 --- a/.forgejo/workflows/build-aarch64.yaml +++ b/.forgejo/workflows/build-aarch64.yaml @@ -2,6 +2,10 @@ on: pull_request: types: [ assigned, opened, synchronize, reopened ] +concurrency: + group: ${{ github.head_ref || github.ref_name }} + cancel-in-progress: true + jobs: build-aarch64: runs-on: aarch64 @@ -41,9 +45,10 @@ jobs: CI_ALPINE_REPO: 'https://ayakael.net/api/packages/forge/alpine' FORGE_REPO_TOKEN: ${{ secrets.FORGE_REPO_TOKEN }} FORGE_REPO_USER: ${{ vars.FORGE_REPO_USER }} + GITHUB_EVENT_NUMBER: ${{ github.event.number }} steps: - name: Setting up environment - run: apk add nodejs curl findutils git gawk + run: apk add nodejs curl findutils git gawk jq - name: Repo pull uses: actions/checkout@v4 - name: Package download diff --git a/.forgejo/workflows/build-x86_64.yaml b/.forgejo/workflows/build-x86_64.yaml index 8731799..90c62cc 100644 --- a/.forgejo/workflows/build-x86_64.yaml +++ b/.forgejo/workflows/build-x86_64.yaml @@ -2,6 +2,10 @@ on: pull_request: types: [ assigned, opened, synchronize, reopened ] +concurrency: + group: ${{ github.head_ref || github.ref_name }} + cancel-in-progress: true + jobs: build-x86_64: runs-on: x86_64 @@ -41,12 +45,14 @@ jobs: CI_ALPINE_REPO: 'https://ayakael.net/api/packages/forge/alpine' FORGE_REPO_TOKEN: ${{ secrets.FORGE_REPO_TOKEN }} FORGE_REPO_USER: ${{ vars.FORGE_REPO_USER }} + GITHUB_EVENT_NUMBER: ${{ github.event.number }} steps: - name: Setting up environment - run: apk add nodejs curl findutils git gawk + run: apk add nodejs curl findutils git gawk jq - name: Repo pull uses: actions/checkout@v4 - name: Package download uses: forgejo/download-artifact@v3 - name: Package deployment run: ${{ github.workspace }}/.forgejo/bin/deploy.sh +