add github workflow #1
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 Docker Image | |
| on: | |
| push: | |
| tags: | |
| - '*' | |
| branches: | |
| - '*' | |
| workflow_dispatch: | |
| jobs: | |
| build-docker-image: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@v6 | |
| - uses: dorny/paths-filter@v4 | |
| id: filter | |
| with: | |
| filters: | | |
| src: | |
| - '.github/**' | |
| - name: Log into registry ghcr.io | |
| if: (github.event_name != 'pull_request' && steps.filter.outputs.src == 'true') || startsWith(github.event.ref, 'refs/tags/v') | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract Docker metadata | |
| if: (github.event_name != 'pull_request' && steps.filter.outputs.src == 'true') || startsWith(github.event.ref, 'refs/tags/v') | |
| id: meta | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: ghcr.io/scpcom/linux-sbc-build | |
| - name: Build and push Docker image | |
| if: (github.event_name != 'pull_request' && steps.filter.outputs.src == 'true') || startsWith(github.event.ref, 'refs/tags/v') | |
| id: build-and-push | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| file: ./.github/scripts/Dockerfile | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| - name: pause | |
| if: (github.event_name != 'pull_request' && steps.filter.outputs.src == 'true') || startsWith(github.event.ref, 'refs/tags/v') | |
| run: sleep 120 | |
| build-image: | |
| strategy: | |
| matrix: | |
| boards: [sun20i, spacemit] | |
| archs: [riscv64] | |
| include: | |
| - boards: n1 | |
| archs: arm64 | |
| - boards: [bpi, nas5xx] | |
| archs: armhf | |
| runs-on: ubuntu-latest | |
| needs: build-docker-image | |
| steps: | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v4 | |
| - name: Get Board Configs | |
| uses: actions/checkout@v6 | |
| - name: Build Images | |
| uses: scpcom/docker-run-action@v4 | |
| with: | |
| image: ghcr.io/scpcom/linux-sbc-build:${{ github.ref_name }} | |
| options: --privileged -v ${{ github.workspace }}/images/:/output -v ${{ github.workspace }}/configs/:/configs/ | |
| run: | | |
| ARCH=${{ matrix.archs }} BOARD=${{ matrix.boards }} GIT_REF=${{ github.ref_name }} ./make_image.sh | |
| chmod 777 /output/ | |
| - name: Pack | |
| run: | | |
| cd images/ | |
| ls -lah | |
| echo "PACKAGE=${{ github.workspace }}/images/*" >> $GITHUB_ENV | |
| - name: Upload package | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: image-files-${{ matrix.boards }}-${{ matrix.archs }} | |
| path: | | |
| ${{env.PACKAGE}} | |
| release: | |
| if: startsWith(github.ref, 'refs/tags/') | |
| runs-on: ubuntu-latest | |
| needs: [build-image] | |
| permissions: write-all | |
| steps: | |
| - name: download firmware | |
| uses: actions/download-artifact@v8 | |
| - name: list images | |
| run: | | |
| ls -lah | |
| ls -lah image-files-*/ | |
| - name: publish artifacts | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| append_body: true | |
| files: | | |
| image-files-*/* |