Skip to content

Commit

Permalink
Create reusable workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
CameronBeneteau committed Dec 2, 2024
1 parent 203c978 commit 132390b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 23 deletions.
16 changes: 5 additions & 11 deletions .github/workflows/build-test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,13 @@ jobs:
cd firmware
make PROJECT=${{ steps.defaults.outputs.project_name }} PLATFORM=${{ steps.defaults.outputs.platform }} build
deploy:
runs-on: self-hosted
needs: build
environment: deploy
steps:
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifact-${{ steps.defaults.outputs.sanitized_project_name }}-${{ steps.defaults.outputs.platform }}
path: firmware/build/${{ steps.defaults.outputs.project_name }}/${{ steps.defaults.outputs.platform }}

# deploy:
# runs-on: self-hosted
# needs: build
# environment: deploy
# steps:
# - name: Upload sanitized project artifacts
# uses: actions/upload-artifact@v4
# with:
# path: firmware/build/${{ steps.defaults.outputs.sanitized_project_name }}-${{ steps.defaults.outputs.platform }}
# name: build-artifact-${{ steps.defaults.outputs.sanitized_project_name }}-${{ steps.defaults.outputs.platform }}
25 changes: 25 additions & 0 deletions .github/workflows/reusable-build-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Build Project

on:
workflow_call:
inputs:
project:
description: 'Project to build (i.e. Demo/Blink)'
required: true
type: string
platform:
description: 'Platform to build for (i.e. cli, stm32f767)'
required: true
type: string

jobs:
build:
runs-on: self-hosted
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Build ${{ github.event.inputs.project }} for ${{ github.event.inputs.platform }}
run: |
cd firmware
make PROJECT=${{ github.event.inputs.project }} PLATFORM=${{ github.event.inputs.platform }} build
17 changes: 5 additions & 12 deletions .github/workflows/test-project-name.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,8 @@ jobs:
test-string-replacement:
runs-on: ubuntu-latest
steps:
- name: Test project name sanitization
id: sanitize
run: |
project_name="Demo/Blink"
sanitized_name="${project_name//\//-}"
echo "Original project name: $project_name"
echo "Sanitized project name: $sanitized_name"
echo "::set-output name=sanitized_name::$sanitized_name"
- name: Display sanitized project name
run: |
echo "Sanitized project name is: ${{ steps.sanitize.outputs.sanitized_name }}"
- name: Build project
uses: ./github-actions/reusable-build-project
with:
project: Demo/Blink
platform: cli

0 comments on commit 132390b

Please sign in to comment.