From dc07d6aa5588651dfedeab807a5c186d904e6ae3 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Wed, 9 Nov 2022 11:44:27 -0500 Subject: [PATCH] initial action commit --- .gitignore | 1 + action.yml | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 .gitignore create mode 100644 action.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..5e25d2e --- /dev/null +++ b/action.yml @@ -0,0 +1,76 @@ +name: "Bento Build" +description: "Composite GitHub action for building Bento images" +inputs: + container-name: + description: "Container name" + required: true + development-dockerfile: + description: "Development Dockerfile path" + required: true + default: "dev.Dockerfile" + production-dockerfile: + description: "Production Dockerfile path" + required: true + default: "Dockerfile" +runs: + using: "composite" + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log into the container registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up development image metadata + id: meta-dev + uses: docker/metadata-action@v4 + with: + images: | + ${{ inputs.container-name }} + flavor: | + latest=false + tags: | + type=raw,value=latest-dev,enable={{is_default_branch}} + type=ref,event=pr + type=sha,prefix=sha- + + - name: Build and push development image + uses: docker/build-push-action@v3 + with: + context: . + file: ${{ inputs.development-dockerfile }} + push: true + tags: ${{ steps.meta-dev.outputs.tags }} + labels: ${{ steps.meta-dev.outputs.labels }} + platforms: linux/amd64,linux/arm64 + + - name: Set up production image metadata + id: meta + uses: docker/metadata-action@v4 + if: ${{ github.event_name == 'release' }} + with: + images: | + ${{ inputs.container-name }} + flavor: | + latest=true + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - name: Build and push production image + uses: docker/build-push-action@v3 + if: ${{ github.event_name == 'release' }} + with: + context: . + file: ${{ inputs.production-dockerfile }} + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64