1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-04-19 19:34:24 +02:00

ci(binary): Trigger workflow on workflow_run, workflow_dispatch

Fixes workflow not triggering for automatically generated releases

PR: #561
This commit is contained in:
slowsage 2024-04-29 05:11:31 -04:00 committed by GitHub
parent 47b6c47724
commit 609dab5822
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,21 +1,43 @@
# .github/workflows/binary.yml
name: Binary name: Binary
on: on:
workflow_run:
workflows: [Deploy]
types: [completed]
release: release:
types: [created] types: [created]
workflow_dispatch:
jobs: jobs:
get_last_release:
runs-on: ubuntu-latest
outputs:
latest_release_tag: ${{ steps.latest-release.outputs.LATEST_RELEASE_TAG }}
steps:
- uses: actions/checkout@v4
- name: Extract the latest release
id: latest-release
run: echo "LATEST_RELEASE_TAG=$(gh release ls --json isLatest,tagName -q '.[] | select(.isLatest == true) | .tagName')" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build: build:
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
name: Build name: Build
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: get_last_release
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
platform: platform:
- {target: x86_64-unknown-linux-gnu, zipext: ".tar.gz"} - {target: x86_64-unknown-linux-gnu, zipext: ".tar.gz"}
- {target: aarch64-unknown-linux-gnu, zipext: ".tar.gz"} - {target: aarch64-unknown-linux-gnu, zipext: ".tar.gz"}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with:
ref: ${{ needs.get_last_release.outputs.latest_release_tag }}
- uses: taiki-e/install-action@v2 - uses: taiki-e/install-action@v2
with: with:
tool: cross tool: cross
@ -34,6 +56,13 @@ jobs:
run: tar -zcvf ${{env.BINARY_NAME}}-${{github.ref_name}}-${{matrix.platform.target}}.tar.gz -C target/${{matrix.platform.target}}/release ${{env.BINARY_NAME}} run: tar -zcvf ${{env.BINARY_NAME}}-${{github.ref_name}}-${{matrix.platform.target}}.tar.gz -C target/${{matrix.platform.target}}/release ${{env.BINARY_NAME}}
- name: Upload to release - name: Upload to release
run: gh release upload ${GITHUB_REF#refs/*/} ${{env.BINARY_NAME}}-${{github.ref_name}}-${{matrix.platform.target}}${{matrix.platform.zipext}} run: gh release upload ${{needs.get_last_release.outputs.latest_release_tag}} ${{env.BINARY_NAME}}-${{github.ref_name}}-${{matrix.platform.target}}${{matrix.platform.zipext}}
env: env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
on-failure:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo 'The triggering workflow Deploy failed'
- run: exit 1