From cb645a7f6b7c1c31ff099e05aca7540b0b74d130 Mon Sep 17 00:00:00 2001 From: Josh Lafleur Date: Sat, 8 Mar 2025 19:39:06 -0800 Subject: [PATCH] Added reusable workflows Added a clean pull which provides the SHA and SHA7 of the current branch Added a build target for any platform or targets --- .github/workflows/reusable/build.yml | 51 +++++++++++++++++++++++ .github/workflows/reusable/clean_pull.yml | 31 ++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 .github/workflows/reusable/build.yml create mode 100644 .github/workflows/reusable/clean_pull.yml diff --git a/.github/workflows/reusable/build.yml b/.github/workflows/reusable/build.yml new file mode 100644 index 00000000..c13a9c62 --- /dev/null +++ b/.github/workflows/reusable/build.yml @@ -0,0 +1,51 @@ +name: Build Platform and Archive + +on: + workflow_dispatch: + inputs: + platform: + required: true + type: string + flags: + default: "-j32" + type: string + build-type: + required: true + options: + - platform + - targets + outputs: + build-artifacts-link: + description: "The link to the github archive of the build artifacts" + value: ${{ jobs.run.outputs.archive-url }} + sha: + description: "The current branch's SHA" + value: ${{ jobs.run.outputs.sha }} + short-sha: + description: "The current branch's short (7) SHA" + value: ${{ jobs.run.outputs.short-sha }} + +jobs: + run: + runs-on: self-hosted + container: + image: docker://ghcr.io/concordia-fsae/containers/ubuntu-noble-lts:v1.0.0 + outputs: + archive-url: ${{ steps.archive.outputs.archive-url }} + sha: ${{ steps.pull.outputs.sha }} + short-sha: ${{ steps.pull.outputs.short-sha }} + steps: + - name: Get Clean Branch + id: pull + uses: concordia-fsae/firmware/.github/workflows/reusable/clean_pull.yml@main + - name: Build Platform ${{ inputs.platform }} + id: build + run: | + scons --${{ inputs.build-type }}=${{ inputs.platform }} ${{ inputs.flags }} + - name: Archive Artifacts + id: archive + uses: actions/upload-artifact@v4 + with: + name: artifacts + path: platform-artifacts/ + diff --git a/.github/workflows/reusable/clean_pull.yml b/.github/workflows/reusable/clean_pull.yml new file mode 100644 index 00000000..9263fdbd --- /dev/null +++ b/.github/workflows/reusable/clean_pull.yml @@ -0,0 +1,31 @@ +name: Clean Working dir, Pull Current Branch, and Retrive Branch Metadata + +on: + workflow_dispatch: + outputs: + sha: + description: "The current branch's SHA" + value: ${{ jobs.run.outputs.sha }} + short-sha: + description: "The current branch's short (7) SHA" + value: ${{ jobs.run.outputs.short-sha }} + +jobs: + run: + outputs: + sha: ${{ steps.sha.outputs.sha }} + short-sha: ${{ steps.sha.outputs.short-sha }} + steps: + - name: Clean + uses: AutoModality/action-clean@1077775f5ef0022fc3a9d6f93377921ea3701fa7 + - name: Pull Branch + uses: actions/checkout@v4 + with: + fetch-depth: 0 + show-progress: 'true' + submodules: 'recursive' + - name: Get SHA and SHA7 + id: sha + run: | + echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT && \ + echo "short-sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT