added github action to push images for main branch on all builds w/ burnettk

This commit is contained in:
jasquat 2023-02-24 11:42:34 -05:00
parent 40dbba88e5
commit 54064a050f
No known key found for this signature in database
2 changed files with 106 additions and 28 deletions

View File

@ -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 }}

View File

@ -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