Github action workflow update #2 #10
Workflow file for this run
This file contains hidden or 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: build-u-boot | |
| env: | |
| IMAGE_BASE: onion/u-boot-builder | |
| S3_BUCKET: repo.onioniot.com | |
| S3_REGION: us-east-1 | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| jobs: | |
| build-image: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Compute variables | |
| id: vars | |
| run: | | |
| date=$(date +'%Y%m%d') | |
| echo "DATE=\"${date}\"" >> "$GITHUB_ENV" | |
| github_sha_hash=${{ github.sha }} | |
| github_sha_short="${github_sha_hash:0:7}" | |
| echo "GITHUB_SHA_SHORT=${github_sha_short}" >> "$GITHUB_ENV" | |
| echo "IMAGE_TAG_LATEST=${{env.IMAGE_BASE}}:latest" >> "$GITHUB_ENV" | |
| echo "IMAGE_TAG_FULL=\"${{env.IMAGE_BASE}}:${date}-${github_sha_short}\"" >> "$GITHUB_ENV" | |
| - name: Prepare u-boot tree | |
| run: | | |
| bash build.sh setup_tree | |
| cat u-boot/Makefile | head -n 8 | |
| - uses: docker/setup-qemu-action@v3 | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build multiarch image and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: | | |
| ${{ env.IMAGE_TAG_LATEST }} | |
| ${{ env.IMAGE_TAG_FULL }} | |
| cache-from: type=registry,ref=onion/u-boot-builder:buildcache | |
| cache-to: type=registry,ref=onion/u-boot-builder:buildcache,mode=max | |
| outputs: | |
| image_tag: ${{ env.IMAGE_TAG_FULL }} | |
| date: ${{ env.DATE }} | |
| github_sha_short: ${{ env.GITHUB_SHA_SHORT }} | |
| build-u-boot: | |
| needs: build-image | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Compute variables | |
| # Github stops propagation of image_tag variable since it thinks it's a secret | |
| id: vars | |
| run: | | |
| echo "IMAGE_TAG_LATEST=${{env.IMAGE_BASE}}:latest" >> "$GITHUB_ENV" | |
| echo "IMAGE_TAG_FULL=\"${{env.IMAGE_BASE}}:${{ needs.build-image.outputs.date }}-${{ needs.build-image.outputs.github_sha_short }}\"" >> "$GITHUB_ENV" | |
| echo "Image tag: ${{ env.IMAGE_TAG_FULL }}" | |
| echo "S3 bucket: ${{ env.S3_BUCKET }}" | |
| - name: Pull image | |
| run: | | |
| docker pull ${{ env.IMAGE_TAG_FULL }} | |
| - name: Build u-boot in container | |
| run: | | |
| cid=$(docker create ${{ env.IMAGE_TAG_FULL }} \ | |
| /bin/bash -c "bash /u-boot-wrapper/build.sh build_uboot") | |
| docker start --attach "$cid" | |
| mkdir -p out | |
| docker cp "$cid":/u-boot-wrapper/u-boot/output/. ./out/ | |
| docker rm "$cid" | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: u-boot-binaries | |
| path: out/* | |
| publish: | |
| needs: build-u-boot | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: u-boot-binaries | |
| path: out | |
| - name: Compute variables | |
| id: vars | |
| shell: bash | |
| run: | | |
| source profile | |
| echo "UBOOT_RELEASE=\"${UBOOT_RELEASE}\"" >> "$GITHUB_ENV" | |
| echo "UBOOT_RELEASE=\"${UBOOT_RELEASE}\"" | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ env.S3_REGION }} | |
| - name: Deploy to S3 | |
| run: aws s3 cp ./out/* s3://${{ env.S3_BUCKET }}/omega2/bootloader/${{ env.UBOOT_RELEASE }}/ |