From 7f90b1af979908ae42451733c2e184c9b961272d Mon Sep 17 00:00:00 2001 From: nitwhiz Date: Fri, 2 Feb 2024 21:06:28 +0100 Subject: [PATCH] add container build workflow --- .github/workflows/build-and-publish.yml | 50 +++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/build-and-publish.yml diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml new file mode 100644 index 0000000..de774cf --- /dev/null +++ b/.github/workflows/build-and-publish.yml @@ -0,0 +1,50 @@ +name: Build and Publish + +on: + push: + branches: + - main + tags: + - "*" + pull_request: + +jobs: + build-and-publish-docker-image: + name: Build docker images and publish + runs-on: ubuntu-latest + + steps: + + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up docker buildx + uses: docker/setup-buildx-action@v3 + with: + platforms: linux/amd64,linux/arm/v7,linux/arm64 + + - name: Login to GitHub Packages + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build omnilock image and publish as specific tag + uses: docker/build-push-action@v5 + if: ${{ github.ref_type == 'tag' }} + with: + context: ./ + tags: "ghcr.io/${{ github.repository }}:${{ github.ref_name }}" + push: true + + - name: Build omnilock image and publish as latest + uses: docker/build-push-action@v4 + if: ${{ github.ref_type != 'tag' }} + with: + context: ./ + tags: "ghcr.io/${{ github.repository }}:latest" + push: ${{ github.ref == 'refs/heads/main' }}