From 6e03c264caa4e1b8d4aaf2cf0f8c073c0b793ec8 Mon Sep 17 00:00:00 2001 From: jasquat Date: Fri, 24 Feb 2023 11:42:34 -0500 Subject: [PATCH] added github action to push images for main branch on all builds w/ burnettk --- .../docker_image_for_main_builds.yml | 94 +++++++++++++++++++ .github/workflows/release_builds.yml | 40 +++----- 2 files changed, 106 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/docker_image_for_main_builds.yml diff --git a/.github/workflows/docker_image_for_main_builds.yml b/.github/workflows/docker_image_for_main_builds.yml new file mode 100644 index 00000000..5122bfcf --- /dev/null +++ b/.github/workflows/docker_image_for_main_builds.yml @@ -0,0 +1,94 @@ +name: Docker Image For Main Builds +# we want to be able to sort by tag name to find the newest and trace back to source control +# on every commit to main: +# frontend:main-20230223164322-b8becd1-45 +# frontend:main-latest +# we settled on: +# main-2023-02-24_16-16-40 +# because the labels on the docker image itself have the git sha and everything else :) +# on every tag: +# frontend:latest + +on: + push: + branches: + - main + +jobs: + create_frontend_docker_image: + runs-on: ubuntu-latest + env: + REGISTRY: ghcr.io + IMAGE_NAME: sartography/spiffworkflow-frontend + permissions: + contents: read + packages: write + steps: + - name: Check out the repository + uses: actions/checkout@v3.0.2 + - name: Log in to the Container registry + uses: docker/login-action@v2.1.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Get current date + id: date + run: echo "::set-output name=date::$(date -u +'%Y-%m-%d_%H-%M-%S')" + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4.3.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch,suffix=-latest + type=ref,event=branch,suffix=-${{ steps.date.outputs.date }} + + - name: Build and push Frontend Docker image + uses: docker/build-push-action@v4.0.0 + with: + # this action doesn't seem to respect working-directory so set context + context: spiffworkflow-frontend + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + create_backend_docker_image: + runs-on: ubuntu-latest + env: + REGISTRY: ghcr.io + IMAGE_NAME: sartography/spiffworkflow-backend + permissions: + contents: read + packages: write + steps: + - name: Check out the repository + uses: actions/checkout@v3.0.2 + - name: Log in to the Container registry + uses: docker/login-action@v2.1.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Get current date + id: date + run: echo "::set-output name=date::$(date -u +'%Y-%m-%d_%H-%M-%S')" + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4.3.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch,suffix=-latest + type=ref,event=branch,suffix=-${{ steps.date.outputs.date }} + + - name: Build and push Backend Docker image + uses: docker/build-push-action@v4.0.0 + with: + # this action doesn't seem to respect working-directory so set context + context: spiffworkflow-backend + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/release_builds.yml b/.github/workflows/release_builds.yml index 59b19e99..31fd3447 100644 --- a/.github/workflows/release_builds.yml +++ b/.github/workflows/release_builds.yml @@ -1,16 +1,11 @@ name: Release Builds -# on every commit to main: -# frontend:main-20230223164322-b8becd1-45 -# frontend:main-latest -# on every tag: -# frontend:latest on: push: tags: [ v* ] jobs: - create_frontend_docker_container: + create_frontend_docker_image: runs-on: ubuntu-latest env: REGISTRY: ghcr.io @@ -21,11 +16,8 @@ jobs: steps: - name: Check out the repository uses: actions/checkout@v3.0.2 - with: - # Disabling shallow clone is recommended for improving relevancy of reporting in sonarcloud - fetch-depth: 0 - name: Log in to the Container registry - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + uses: docker/login-action@v2.1.0 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} @@ -33,13 +25,12 @@ jobs: - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + uses: docker/metadata-action@v4.3.0 with: - context: spiffworkflow-frontend images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - name: Build and push Frontend Docker image - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + uses: docker/build-push-action@v4.0.0 with: # this action doesn't seem to respect working-directory so set context context: spiffworkflow-frontend @@ -47,7 +38,7 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - create_backend_docker_container: + create_backend_docker_image: runs-on: ubuntu-latest env: REGISTRY: ghcr.io @@ -58,11 +49,8 @@ jobs: steps: - name: Check out the repository uses: actions/checkout@v3.0.2 - with: - # Disabling shallow clone is recommended for improving relevancy of reporting in sonarcloud - fetch-depth: 0 - name: Log in to the Container registry - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + uses: docker/login-action@v2.1.0 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} @@ -70,12 +58,12 @@ jobs: - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + uses: docker/metadata-action@v4.3.0 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - name: Build and push Backend Docker image - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + uses: docker/build-push-action@v4.0.0 with: # this action doesn't seem to respect working-directory so set context context: spiffworkflow-backend @@ -95,11 +83,8 @@ jobs: steps: - name: Check out the repository uses: actions/checkout@v3.0.2 - with: - # Disabling shallow clone is recommended for improving relevancy of reporting in sonarcloud - fetch-depth: 0 - name: Log in to the Container registry - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + uses: docker/login-action@v2.1.0 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} @@ -107,13 +92,12 @@ jobs: - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + uses: docker/metadata-action@v4.3.0 with: - context: connector-proxy-demo images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - name: Build and push the connector proxy - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + uses: docker/build-push-action@v4.0.0 with: # this action doesn't seem to respect working-directory so set context context: connector-proxy-demo @@ -123,7 +107,7 @@ jobs: quickstart-guide-test: runs-on: ubuntu-latest - needs: [create_frontend_docker_container, create_backend_docker_container, create_demo-proxy] + needs: [create_frontend_docker_image, create_backend_docker_image, create_demo-proxy] steps: - name: Checkout uses: actions/checkout@v3