feature/bookwormV2 #301
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: pi4j-os | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
main: | |
runs-on: ubuntu-20.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
flavor: | |
- Basic | |
- CrowPi | |
- Picade | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Prepare build environment | |
id: env | |
run: | | |
echo "RELEASE_VERSION=$(echo "${GITHUB_REF#refs/*/}" | sed 's/\//-/g' | tr -cd '[0-9a-zA-Z.]-')" >> $GITHUB_OUTPUT | |
- name: Build OS image with Packer | |
id: build | |
if: >- | |
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))) | |
|| | |
(github.event_name == 'pull_request') | |
env: | |
WORKSPACE_PATH: ${{ github.workspace }} | |
run: >- | |
docker run | |
--rm --privileged | |
--workdir /github/workspace | |
-v /dev:/dev | |
-v /home/runner/work/_temp/_github_home:/github/home | |
-v /home/runner/work/_temp/_github_workflow:/github/workflow | |
-v "${WORKSPACE_PATH}:/github/workspace" | |
mkaczanowski/packer-builder-arm | |
build "${{ matrix.flavor }}.pkr.hcl" | |
- name: Upload OS image as build artifact | |
if: steps.build.outcome == 'success' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Pi4J-${{ matrix.flavor }}-OS-image | |
path: Pi4J-${{ matrix.flavor }}-OS.img.zip | |
- name: Publish OS image to external repository | |
if: >- | |
github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) | |
env: | |
SFTP_SERVER: ${{ secrets.REPO_SFTP_SERVER }} | |
SFTP_USERNAME: ${{ secrets.REPO_SFTP_USERNAME }} | |
SSHPASS: ${{ secrets.REPO_SFTP_PASSWORD }} | |
RELEASE_VERSION: ${{ steps.env.outputs.RELEASE_VERSION }} | |
run: | | |
sshpass -e sftp -oBatchMode=no -oStrictHostKeyChecking=no -b - "${SFTP_USERNAME}@${SFTP_SERVER}" << EOS | |
put "Pi4J-${{ matrix.flavor }}-OS.img.zip" "Pi4J-${{ matrix.flavor }}-OS-${RELEASE_VERSION}.img.zip" | |
put "Pi4J-${{ matrix.flavor }}-OS.img.sha256" "Pi4J-${{ matrix.flavor }}-OS-${RELEASE_VERSION}.img.sha256" | |
EOS | |
update-download-readme: | |
runs-on: ubuntu-20.04 | |
if: >- | |
github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) | |
needs: | |
- main | |
steps: | |
- name: Trigger dynamic README update of Pi4J/download | |
env: | |
GITHUB_PAT: ${{ secrets.PI4J_BOT_GITHUB_PAT }} | |
run: >- | |
curl | |
--silent --show-error --fail --fail | |
-X POST | |
-H "Accept: application/vnd.github.v3+json" | |
-H "Authorization: Token ${GITHUB_PAT}" | |
https://api.github.com/repos/pi4j/download/actions/workflows/dynamic-readme.yml/dispatches | |
-d '{"ref":"refs/heads/main"}' |