Skip to content

Commit

Permalink
feat(.github): split gen/exec of actionsflow workflows
Browse files Browse the repository at this point in the history
This change separates the generation of workflow files by actionsflow from the
execution of those workflow files using nektos/act project. The generated files
are shared between jobs by uploading an artifact to github. The artifact is
always deleted, even if running act was unsuccessful.
  • Loading branch information
qlonik committed Jun 10, 2024
1 parent b25ecca commit b9c3af7
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions .github/workflows/actionsflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ on:
required: false
default: "false"

concurrency: actionsflow

jobs:
run:
generate-workflows:
name: Generate workflows from Actionsflow
runs-on: ["gha-home-ops"]
name: Run
concurrency: actionsflow
outputs:
run-act: ${{ steps.check-workflow-files.outputs.present }}
artifact-id: ${{ steps.upload-configs.outputs.artifact-id }}
steps:
- uses: actions/checkout@v4

Expand All @@ -58,6 +62,29 @@ jobs:
echo "present=true" >> "$GITHUB_OUTPUT"
fi
- name: Upload generated workflows
id: upload-configs
if: ${{ steps.check-workflow-files.outputs.present == 'true' }}
uses: actions/upload-artifact@v4
with:
name: actionsflow-act-config
path: ./dist
if-no-files-found: error
retention-days: 1

run-act:
name: Run act
runs-on: ["gha-home-ops"]
needs: generate-workflows
if: ${{ needs.generate-workflows.outputs.run-act == 'true' }}
steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: actionsflow-act-config
path: ./dist

- name: Install act
if: ${{ steps.check-workflow-files.outputs.present == 'true' }}
run: curl -fsSL https://raw.githubusercontent.com/nektos/act/master/install.sh | bash -s -- -b ~/bin/
Expand All @@ -77,3 +104,13 @@ jobs:
--secret-file ./dist/.secrets \
--env-file ./dist/.env \
--platform ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latest
- name: Delete artifacts
if: ${{ always() }}
uses: actions/github-script@v7
with:
script: |
github.rest.actions.deleteArtifact({
artifact_id: "${{ needs.generate-workflows.outputs.artifact-id }}",
...context.repo,
})

0 comments on commit b9c3af7

Please sign in to comment.