From 5e50f9ead753a6adffce54b347d5274073a56407 Mon Sep 17 00:00:00 2001 From: Jacob Heider Date: Tue, 3 Jan 2023 18:18:49 -0500 Subject: [PATCH] fix bottle.yml:cleanup --- .github/workflows/bottle.yml | 14 ++++++++++---- scripts/fetch-pr-artifacts.ts | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/bottle.yml b/.github/workflows/bottle.yml index d86985f8..cbe92cdc 100644 --- a/.github/workflows/bottle.yml +++ b/.github/workflows/bottle.yml @@ -28,6 +28,7 @@ jobs: outputs: srcs: ${{ env.srcs }} built: ${{ env.built }} + pr: ${{ env.PR }} steps: - uses: actions/checkout@v3 with: @@ -57,7 +58,7 @@ jobs: name: ${{ matrix.platform.name }} path: tea.xyz/var/pantry - - run: scripts/fetch-pr-artifacts.ts ${{ github.repository }} ${{ github.sha }} ${{ matrix.platform.name }} + - run: scripts/fetch-pr-artifacts.ts ${{ github.repository }} ${{ github.sha }} ${{ matrix.platform.name }} >>$GITHUB_ENV if: ${{ !inputs.new-version }} env: GITHUB_TOKEN: ${{github.token}} @@ -231,8 +232,8 @@ jobs: cleanup: runs-on: ubuntu-latest - needs: [upload] - if: startsWith(github.ref, 'refs/pull/') && startsWith(github.repository, 'teaxyz/pantry.') + needs: [bottle, upload] + if: ${{ !inputs.new-version }} steps: - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v1 @@ -242,8 +243,13 @@ jobs: aws-region: us-east-1 - run: | REPO=$(echo ${{github.repository}} | sed -e 's_teaxyz/__') - PR=$(echo ${{github.ref}} | sed -e 's_refs/pull/\(.*\)/merge_\1_') + + if test -z "$PR"; then + echo "no PR to clean up" + exit 0 + fi aws s3 rm --recursive s3://$AWS_S3_CACHE/pull-request/$REPO/$PR env: AWS_S3_CACHE: ${{ secrets.AWS_S3_CACHE }} + PR: ${{ needs.bottle.outputs.pr }} diff --git a/scripts/fetch-pr-artifacts.ts b/scripts/fetch-pr-artifacts.ts index 9f995674..e9708c93 100755 --- a/scripts/fetch-pr-artifacts.ts +++ b/scripts/fetch-pr-artifacts.ts @@ -42,6 +42,8 @@ const artifacts = (await bucket.getObject(key)) ?? panic("No artifacts found") const file = await Deno.open("artifacts.tgz", { create: true, write: true }) await artifacts.body.pipeTo(file.writable) +Deno.stdout.write(new TextEncoder().encode(`PR=${pr}`)) + /// Functions /// -------------------------------------------------------------------------------