Copy bin/hex post build to another dir for github sync

I just started using vscode/pio a month ago. I’m primarily working on a Teensy 4.1 project and I’m also just starting to get the hang of using github integration. I’d like to include the bin & hex files in the github repo but currently the entire .pio directory is exclude from github by gitignore. I see the bin/hex files in .pio\build\teensy41 directory and ideally I’d like the bin/hex on the repo in a different directory, maybe \test. I read about the pre/post script option but it’s beyond my current abilities, is there another way to achieve this?

How about a extra step in the github action?

Here is an example that copies the resulting firmware.bin and firmware.elf to the /artifacts directory and upload them to the artifacts:

name: Build Firmware

on:
  push:
  pull_request:
  workflow_dispatch: 

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4

      - name: Set up PlatformIO
        uses: actions/setup-python@v5
        with:
          python-version: "3.x"

      - name: Install PlatformIO
        run: pip install platformio

      - name: Build Firmware
        run: pio run

      - name: Copy Firmware to Artifacts
        run: |
          mkdir -p artifacts
          cp .pio/build/c3/firmware.bin artifacts/
          cp .pio/build/c3/firmware.elf artifacts/

      - name: Upload Firmware as Artifact
        uses: actions/upload-artifact@v4
        with:
          name: firmware
          path: artifacts/

Are you talking about using GitHub Actions to create a workflow.yml? Your example looks a bit different then the GitHub Actions demo/quickstart example. I’m lost as to how to implement your suggestion.

I am not sure if I have understood you correctly. But your question was about CI integration with Github Actions? Have a look at the example from PlatformIO: GitHub Actions — PlatformIO v6.1 documentation

You wanted to copy the resulting firmware.bin and firmware.hex to another directory in your repository. You can easily do this with a cp command:

 - name: Copy Firmware
 run: |
 mkdir -p <dest directory>
 cp .pio/build/<envname>/firmware.bin <dest directory>/
 cp .pio/build/<envname>/firmware.hex <dest directory>/

Note: <dest directory> and <envname> from above are placeholders!

I apologize if I have misunderstood you.

I think you are giving me correct guidance but I just don’t understand how to implement GitHub actions. I appreciate your help but I have just modified our gitignore to include the bin/hex file where they lay.

Sorry, misunderstanding on my side.

This statement lead me to github integration.

It is just creating a file in your prepostiory: ./github/workflows/some_filename.yml
The yml from above will automatcly compile your code on github if you push new code, create a pull request or start the workflow manually.
You will find the result in the “Actions” tab in your github repository.

The firmware will be compiled directly on github and can be downloaded as artifacts.