From f257bd3cb7460aa2c9572b8f29732d2ad3cf172f Mon Sep 17 00:00:00 2001 From: Simon Frei Date: Fri, 14 Jul 2023 21:14:25 +0200 Subject: [PATCH] Add GHA workflow to build the builder image --- .github/workflows/build.yaml | 18 +++++++++ .github/workflows/image-builder-template.yaml | 40 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/image-builder-template.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 000000000..fc9e119da --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,18 @@ +name: Build/Release + +on: + pull_request: + workflow_dispatch: + +jobs: + build-image: + if: github.event_name == 'pull_request' + uses: ./.github/workflows/image-builder-template.yaml + with: + push: false + + push-image: + if: github.event_name == 'workflow_dispatch' + uses: ./.github/workflows/image-builder-template.yaml + with: + push: true diff --git a/.github/workflows/image-builder-template.yaml b/.github/workflows/image-builder-template.yaml new file mode 100644 index 000000000..fe6dfe252 --- /dev/null +++ b/.github/workflows/image-builder-template.yaml @@ -0,0 +1,40 @@ +name: Image Builder Template + +on: + workflow_call: + inputs: + push: + required: true + type: boolean + +env: + # Our build metadata + BUILD_USER: builder + BUILD_HOST: github.syncthing.net + # template var + image: ghcr.io/syncthing/syncthing-android-builder + +jobs: + build-image: + name: Build Builder Docker + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - uses: docker/setup-buildx-action@v2 + + - uses: docker/login-action@v2 + if: ${{ inputs.push }} + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: docker/build-push-action@v4 + with: + context: . + file: ./docker/Dockerfile + tags: '${{ env.image }}:latest,${{ env.image }}:${{ github.sha }}' + push: ${{ inputs.push }}