From 2792180cd40d34e362f0e9c81a7fdcd532894d8a Mon Sep 17 00:00:00 2001 From: Nick Knight Date: Wed, 17 May 2023 09:05:27 +0100 Subject: [PATCH] add build yaml --- .github/workflows/build.yaml | 76 ++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..7474f69 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,76 @@ +name: Build + +# Controls when the workflow will run +on: + workflow_dispatch: + push: + branches: + - 'main' + tags: + - 'v*.*.*' + pull_request: + branches: + - 'main' + +#GH +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + # Get the repository's code + - name: Checkout + uses: actions/checkout@v3 + # https://github.com/docker/setup-qemu-action + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + # https://github.com/docker/setup-buildx-action + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + - name: Login to Docker Hub + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and export to Docker + uses: docker/build-push-action@v4 + with: + context: . + load: true + tags: docker.io/tinpotnick/rrdb:test + + #- name: Test + # Use --exit so we don't hang a test on exception + # run: | + # docker run --rm docker.io/tinpotnick/rrdb:test /bin/sh -c 'npm run github:check' + + - name: Docker meta + id: ourdockertags + uses: docker/metadata-action@v3 + with: + # list of Docker images to use as base name for tags + images: | + docker.io/tinpotnick/rrdb + # Docker tags based on the following events/attributes + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.ourdockertags.outputs.tags }} + labels: ${{ steps.ourdockertags.outputs.labels }}