From 096fb972860ecb4dea206c502be4ddbfadc87c01 Mon Sep 17 00:00:00 2001 From: Peter Kohout Date: Mon, 18 Dec 2023 01:16:52 +0100 Subject: [PATCH] CI now pushing images to ghcr --- .github/workflows/docker.yml | 42 +++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 02e9f36..874c020 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -4,19 +4,45 @@ name: Docker Container Build on: push: - branches: [ "master", "mqtt-test" ] + branches: [ "master"] pull_request: branches: [ "master" ] - +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} jobs: build: - runs-on: ubuntu-latest - steps: - uses: actions/checkout@v2 - - name: Build the Simulator image - run: docker build Simulator/. --tag simulator_frontend:$(date +%s) - - name: Build the Frontend image - run: docker build frontend/. --tag simulator_backend:$(date +%s) \ No newline at end of file + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: metaSimulator + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/simulator + - name: Build and push simulator image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: "Simulator" + push: true + tags: ${{ steps.metaSimulator.outputs.tags }} + labels: ${{ steps.metaSimulator.outputs.labels }} + - name: Extract metadata (tags, labels) for Docker + id: metaFrontend + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/frontend + - name: Build and push frontend image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: "frontend" + push: true + tags: ${{ steps.metaFrontend.outputs.tags }} + labels: ${{ steps.metaFrontend.outputs.labels }}