Skip to content

Commit

Permalink
docs(action): add example workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
AtomicFS committed Sep 18, 2023
1 parent d8aad67 commit 8386001
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 8 deletions.
130 changes: 130 additions & 0 deletions .github/workflows/example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
---
# Example of using firmware-action

name: example
on:

Check warning on line 5 in .github/workflows/example.yml

View workflow job for this annotation

GitHub Actions / megalinter

5:1 [truthy] truthy value should be one of [false, true]
pull_request:
merge_group:
push:

# branches:
# - main

env:
APPLY_FIXES: none
APPLY_FIXES_EVENT: pull_request
APPLY_FIXES_MODE: commit
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

permissions:
contents: read

jobs:
# Example of building coreboot
build-coreboot:
runs-on: ubuntu-latest
strategy:
matrix:
coreboot-version:
[
'4.19',
'4.20.1',
'4.21'
]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Clone coreboot repo
run: |
git clone --branch "${{ matrix.coreboot-version }}" --depth 1 https://review.coreboot.org/coreboot my_super_dooper_awesome_coreboot
- name: Move my defconfig into place (filename must not contain '.defconfig')
run: |
mv "tests/coreboot_${{ matrix.coreboot-version }}/seabios.defconfig" "seabios_defconfig"
- name: firmware-action
uses: ./
#uses: 9elements/firmware-action

Check warning on line 49 in .github/workflows/example.yml

View workflow job for this annotation

GitHub Actions / megalinter

49:10 [comments] missing starting space in comment
with:
target: coreboot
sdk_version: "coreboot_${{ matrix.coreboot-version }}:main"
#architecture: x86 # default

Check warning on line 53 in .github/workflows/example.yml

View workflow job for this annotation

GitHub Actions / megalinter

53:12 [comments] missing starting space in comment
repo_path: my_super_dooper_awesome_coreboot
defconfig_path: "seabios_defconfig"
#output: "output" # default

Check warning on line 56 in .github/workflows/example.yml

View workflow job for this annotation

GitHub Actions / megalinter

56:12 [comments] missing starting space in comment

# Example of building Linux kernel
build-linux:
runs-on: ubuntu-latest
strategy:
matrix:
linux-version: [6.1.45]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Prepare linux kernel
run: |
export LINUX_MAJOR_VERSION=$(echo "${{ matrix.linux-version }}" | sed -E 's/\..*//g')
echo "linux-version: ${{ matrix.linux-version }}"
echo "LINUX_MAJOR_VERSION: ${LINUX_MAJOR_VERSION}"
# Download source files
wget --quiet "https://cdn.kernel.org/pub/linux/kernel/v${LINUX_MAJOR_VERSION}.x/linux-${{ matrix.linux-version }}.tar.xz"
wget --quiet "https://cdn.kernel.org/pub/linux/kernel/v${LINUX_MAJOR_VERSION}.x/linux-${{ matrix.linux-version }}.tar.sign"
unxz "linux-${{ matrix.linux-version }}.tar.xz" >/dev/null
# Verify GPG signature
gpg2 --locate-keys torvalds@kernel.org gregkh@kernel.org
gpg2 --verify "linux-${{ matrix.linux-version }}.tar.sign"
# Extract
tar -xvf "linux-${{ matrix.linux-version }}.tar"
- name: Move my defconfig into place (filename must not contain '.defconfig')
run: |
mv "tests/linux_${{ matrix.linux-version }}/linux.defconfig" "ci_defconfig"
- name: firmware-action
uses: ./
#uses: 9elements/firmware-action

Check warning on line 88 in .github/workflows/example.yml

View workflow job for this annotation

GitHub Actions / megalinter

88:10 [comments] missing starting space in comment
with:
target: linux
sdk_version: "linux_${{ matrix.linux-version }}:main"
#architecture: x86 # default

Check warning on line 92 in .github/workflows/example.yml

View workflow job for this annotation

GitHub Actions / megalinter

92:12 [comments] missing starting space in comment
repo_path: "linux-${{ matrix.linux-version }}"
defconfig_path: "ci_defconfig"
#output: "output" # default

Check warning on line 95 in .github/workflows/example.yml

View workflow job for this annotation

GitHub Actions / megalinter

95:12 [comments] missing starting space in comment

# Example of building EDK2
build-edk2:
runs-on: ubuntu-latest
strategy:
matrix:
edk2-version:
[
'edk2-stable202208',
'edk2-stable202211'
]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Clone edk2 repo
run: |
git clone --recurse-submodules --branch "${{ matrix.edk2-version }}" --depth 1 https://github.com/tianocore/edk2.git Edk2
- name: Prepare file with build arguments
run: |
echo "-t GCC5 -D BOOTLOADER=COREBOOT -D TPM_ENABLE=TRUE -D NETWORK_IPXE=TRUE" > "edk2_config.cfg"
- name: firmware-action
uses: ./
#uses: 9elements/firmware-action

Check warning on line 120 in .github/workflows/example.yml

View workflow job for this annotation

GitHub Actions / megalinter

120:10 [comments] missing starting space in comment
with:
target: edk2
sdk_version: "${{ matrix.edk2-version }}:main"
architecture: X64
repo_path: "Edk2"
defconfig_path: "edk2_config.cfg"
#output: "output" # default

Check warning on line 127 in .github/workflows/example.yml

View workflow job for this annotation

GitHub Actions / megalinter

127:12 [comments] missing starting space in comment
edk2__platform: "UefiPayloadPkg/UefiPayloadPkg.dsc"
#edk2__release_type: DEBUG # default

Check failure on line 130 in .github/workflows/example.yml

View workflow job for this annotation

GitHub Actions / megalinter

130:1 [empty-lines] too many blank lines (1 > 0)
7 changes: 5 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,18 @@ inputs:
description: |
*architecture* specifies target architecture, such as 'x86' or 'arm64'.
required: true
default: 'x86'
repo_path:
description: |
*repo_path* gives the (relative) path to the target (firmware) repository.
If the current repository contains the selected target, specify: '.'
Otherwise the path should point to the target (firmware) repository
submodule that had previously been checked out.
required: true
default: '.'
defconfig_path:
description: |
*defconfig_path* gives the (relative to repo_path) path to the defconfig that
*defconfig_path* gives the (relative) path to the defconfig that
should be used to build the target.
For coreboot and linux this is a defconfig.
For EDK2 this is a one-line file containing the build arguments
Expand All @@ -55,8 +57,9 @@ inputs:
required: true
output:
description: |
*output* specifies the (relative) path where to place the produced files
*output* specifies the (relative) path to directory into which place the produced files
required: true
default: 'output'

#-------------------------------
# Inputs specific for coreboot target
Expand Down
24 changes: 18 additions & 6 deletions dist/invoke-action.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,30 @@ main();
function main() {
console.log("Node Version: ", process.version);

// Execute the main Go program
const spawnSyncReturns = spawnSync('go', ['run', 'main.go'], {
// Compile Go program
console.log("Building ...");
const goBuildReturns = spawnSync('go', ['build', '-o', '../action.bin'], {
cwd: path.join(process.cwd(), 'action'),
env: process.env,
stdio: 'inherit',
encoding: 'utf-8'
});
// Check the exit code
const statusBuild = goBuildReturns.status;
if (statusBuild !== 0) {
process.exit(statusBuild);
}

// Run Go program
console.log("Running ...");
const binRunReturns = spawnSync('./action.bin', [], {
cwd: process.cwd(),
stdio: 'inherit',
encoding: 'utf-8'
});
// Check the exit code
const status = spawnSyncReturns.status;
if (typeof status === 'number') {
process.exit(status);
const statusRun = binRunReturns.status;
if (typeof statusRun === 'number') {
process.exit(statusRun);
}

// If we're here, something went wrong
Expand Down

0 comments on commit 8386001

Please sign in to comment.