ci(build): merge the docker and build workflow #93
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" | |
| on: # yamllint disable-line rule:truthy | |
| push: | |
| branches: [master] | |
| concurrency: | |
| group: ${{ github.ref_name }} | |
| cancel-in-progress: true | |
| defaults: | |
| run: | |
| shell: bash | |
| permissions: | |
| contents: read | |
| jobs: | |
| check-docker-files: | |
| name: Check for updated docker files | |
| runs-on: ubuntu-latest | |
| outputs: | |
| changed: ${{ steps.changed-files.outputs.any_changed }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| persist-credentials: false | |
| - name: Get changed docker files | |
| id: changed-files | |
| uses: tj-actions/changed-files@v47 | |
| with: | |
| files: docker/** | |
| docker: | |
| name: Build the container | |
| runs-on: ubuntu-latest | |
| needs: check-docker-files | |
| if: needs.check-docker-files.outputs.changed == 'true' | |
| permissions: | |
| packages: write # Required to push image to ghcr.io | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Log into registry ${{ env.REGISTRY }} | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v6 | |
| with: | |
| flavor: latest=true | |
| tags: | | |
| type=ref,event=branch | |
| type=sha | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v7 | |
| with: | |
| platforms: linux/amd64 | |
| context: docker | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| collect: | |
| name: Collect DEVFAMILY and OS combinations | |
| runs-on: ubuntu-latest | |
| container: | |
| image: ghcr.io/texasinstruments/processor-sdk-doc:latest | |
| options: --entrypoint /bin/bash | |
| outputs: | |
| build-matrix: "${{ steps.matrix.outputs.matrix }}" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| persist-credentials: false | |
| - name: Create build matrix | |
| id: matrix | |
| run: | | |
| ./bin/build_matrix.py | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| container: | |
| image: ghcr.io/texasinstruments/processor-sdk-doc:latest | |
| options: --entrypoint /bin/bash | |
| needs: collect | |
| strategy: | |
| matrix: | |
| include: "${{ fromJSON(needs.collect.outputs.build-matrix) }}" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| persist-credentials: false | |
| - name: Add directory to safe dir overrides | |
| run: | | |
| git config --global --add safe.directory "$PWD" | |
| - name: Build ${{ matrix.device }} | |
| env: | |
| DEVFAMILY: ${{ matrix.device }} | |
| OS: ${{ matrix.os }} | |
| run: | | |
| make VERSION=${GITHUB_REF_NAME} | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: ${{ matrix.device }}-${{ matrix.os }} | |
| path: build/ | |
| retention-days: 1 |