Skip to content

Commit

Permalink
CI: generalise artefact handling
Browse files Browse the repository at this point in the history
* on PR syncs, delete draft releases on Linux runners only
* delete draft releases when unmerged PRs are closed

Change-type: patch
  • Loading branch information
ab77 committed Nov 8, 2022
1 parent 6a39f58 commit e3618b9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 22 deletions.
38 changes: 38 additions & 0 deletions .github/actions/always/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: cleanup
# https://github.com/product-os/flowzone/tree/master/.github/actions
inputs:
json:
description: "JSON stringified object containing all the inputs from the calling workflow"
required: true
secrets:
description: "JSON stringified object containing all the secrets from the calling workflow"
required: true

# --- custom environment
VERBOSE:
type: string
default: "true"

runs:
# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
using: "composite"
steps:
# delete draft releases if the pull request is closed without merging
- name: Delete draft release
if: |
runner.os == 'Linux' &&
github.event_name == 'pull_request' &&
github.event.pull_request.merged == false &&
github.event.action == 'closed'
shell: bash --noprofile --norc -eo pipefail -x {0}
run: |
set -ea
[[ '${{ inputs.VERBOSE }}' =~ on|On|Yes|yes|true|True ]] && set -x
gh release delete --yes '${{ github.event.pull_request.head.ref }}' || true
env:
GITHUB_TOKEN: ${{ fromJSON(inputs.secrets).FLOWZONE_TOKEN }}
17 changes: 2 additions & 15 deletions .github/actions/publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,10 @@ runs:
path: ${{ runner.temp }}

- name: Extract custom source artifact
if: runner.os != 'Windows'
shell: bash --noprofile --norc -eo pipefail -x {0}
shell: pwsh
working-directory: .
run: tar -xf ${{ runner.temp }}/custom.tgz

- name: Extract custom source artifact
if: runner.os == 'Windows'
shell: powershell
working-directory: .
run: tar -xf ${{ runner.temp }}\custom.tgz

- name: Setup Node.js
uses: actions/setup-node@v3
with:
Expand Down Expand Up @@ -233,15 +226,9 @@ runs:
dist/latest*.yml
- name: Compress custom source
if: runner.os != 'Windows'
shell: bash --noprofile --norc -eo pipefail -x {0}
shell: pwsh
run: tar -acf ${{ runner.temp }}/custom.tgz .

- name: Compress custom source
if: runner.os == 'Windows'
shell: powershell
run: tar -acf ${{ runner.temp }}\custom.tgz .

- name: Upload custom artifact
uses: actions/upload-artifact@v3
with:
Expand Down
9 changes: 2 additions & 7 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ runs:
using: "composite"
steps:
- name: Delete previous draft release
if: runner.os == 'Linux'
shell: bash --noprofile --norc -eo pipefail -x {0}
run: |
set -ea
Expand Down Expand Up @@ -59,15 +60,9 @@ runs:
ELECTRON_NO_ATTACH_CONSOLE: true

- name: Compress custom source
if: runner.os != 'Windows'
shell: bash --noprofile --norc -eo pipefail -x {0}
shell: pwsh
run: tar -acf ${{ runner.temp }}/custom.tgz .

- name: Compress custom source
if: runner.os == 'Windows'
shell: powershell
run: tar -acf ${{ runner.temp }}\custom.tgz .

- name: Upload custom artifact
uses: actions/upload-artifact@v3
with:
Expand Down

0 comments on commit e3618b9

Please sign in to comment.