From 3295b1c3d07a07cca9f1e4c78ffe1dc403229268 Mon Sep 17 00:00:00 2001 From: Craig Gill Date: Mon, 13 Nov 2023 14:04:43 -0800 Subject: [PATCH] setup gh action --- .github/workflows/build-tagged-image.yml | 47 ++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/build-tagged-image.yml diff --git a/.github/workflows/build-tagged-image.yml b/.github/workflows/build-tagged-image.yml new file mode 100644 index 0000000..65d64f7 --- /dev/null +++ b/.github/workflows/build-tagged-image.yml @@ -0,0 +1,47 @@ +name: Build & Push Docker Image to GitHub + +on: + push: + tags: + - "*.*.*" + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build_image: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GHCR + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata for the Docker image + id: meta + uses: docker/metadata-action@v5.0.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: ./app + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + RELEASE_TAG=${{ vars.RELEASE_TAG }}