From a6ad144eac410e58f09828bfe3899764a5a33b51 Mon Sep 17 00:00:00 2001 From: "Hannes F. Kuchelmeister" Date: Wed, 15 Sep 2021 14:54:24 +0200 Subject: [PATCH] add automatic building and pushing of tags --- .github/workflows/build-push-tagged.yml | 64 +++++++++++++++++++++++++ docker-compose.yml | 2 +- 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-push-tagged.yml diff --git a/.github/workflows/build-push-tagged.yml b/.github/workflows/build-push-tagged.yml new file mode 100644 index 0000000..0b60335 --- /dev/null +++ b/.github/workflows/build-push-tagged.yml @@ -0,0 +1,64 @@ +name: build-push-tagged + +on: + push: + tags: + - '*.*.*' + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + # TO get the tag name + - name: Get the tag name + run: echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV + - name: Checkout repository + uses: actions/checkout@v2 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + # list of Docker images to use as base name for tags + images: | + ghcr.io/13hannes11/ics-proxy + # generate Docker tags based on the following events/attributes + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + diff --git a/docker-compose.yml b/docker-compose.yml index 4f28f2e..cad50e4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: '3' services: ics-proxy: container_name: ics-proxy - image: 13hannes11/ics-proxy + image: ghcr.io/13hannes11/ics-proxy:latest env_file: .env ports: - "8080:8080"