Skip to content

Commit

Permalink
Merge branch 'main' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
robkooper committed Jun 8, 2024
2 parents b79bcc0 + c8730ac commit 91b2b82
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 55 deletions.
112 changes: 59 additions & 53 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ on:
- main
- staging
- expt
tags:
- "v*.*.*"
pull_request:

# Certain actions will only run when this is the main repo.
Expand All @@ -26,65 +28,69 @@ jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

# calculate some variables that are used later
- name: github branch
# create metadata for image
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
${{ env.DOCKERHUB_ORG }}/frontend
ghcr.io/${{ github.repository_owner }}/frontend
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
# setup docker build
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3

- name: Inspect Builder
run: |
BRANCH=${GITHUB_REF##*/}
if [ "$BRANCH" == "main" ]; then
TAGS="latest,$(date +'%Y%m%d')"
else
TAGS="$BRANCH"
fi
TAGS="${TAGS},${BRANCH}-${{ github.run_number }}"
echo "TAGS=${TAGS}" >> $GITHUB_ENV
echo "GITHUB_BRANCH=${BRANCH}" >> $GITHUB_ENV
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
# build the docker image, this will always run to make sure
# the Dockerfile still works.
- name: Build image
uses: elgohr/Publish-Docker-Github-Action@2.22
env:
BRANCH: ${{ env.GITHUB_BRANCH }}
BUILDNUMBER: ${{ github.run_number }}
GITSHA1: ${{ github.sha }}
# login to registries
- name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: docker.pkg.github.com
name: ${{ github.repository_owner }}/${{ github.event.repository.name }}/frontend
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
tags: "${{ env.TAGS }}"
buildargs: BRANCH,BUILDNUMBER,GITSHA1
no_push: true
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

# this will publish to github container registry
- name: Publish to GitHub
if: github.event_name == 'push' && github.repository == env.MAIN_REPO
uses: elgohr/Publish-Docker-Github-Action@2.22
env:
BRANCH: ${{ env.GITHUB_BRANCH }}
BUILDNUMBER: ${{ github.run_number }}
GITSHA1: ${{ github.sha }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
name: ${{ github.repository_owner }}/frontend
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_PASSWORD }}
tags: "${{ env.TAGS }}"
buildargs: BRANCH,BUILDNUMBER,GITSHA1
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# this will publish to the classtranscribe dockerhub repo
- name: Publish to Docker Hub
if: github.event_name == 'push' && github.repository == env.MAIN_REPO
uses: elgohr/Publish-Docker-Github-Action@2.22
env:
BRANCH: ${{ env.GITHUB_BRANCH }}
BUILDNUMBER: ${{ github.run_number }}
GITSHA1: ${{ github.sha }}
# build the docker images
- name: Build and push frontend
uses: docker/build-push-action@v5
with:
name: ${{ env.DOCKERHUB_ORG }}/frontend
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
tags: "${{ env.TAGS }}"
buildargs: BRANCH,BUILDNUMBER,GITSHA1
context: .
#push: ${{ github.event_name != 'pull_request' }}
push: true
platforms: "linux/amd64,linux/arm64"
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=classtranscribe/frontend-pipeline:buildcache
cache-to: type=registry,ref=classtranscribe/frontend:buildcache,mode=max
build-args: |
BRANCH=${{ steps.meta.outputs.version }}
BUILDNUMBER=${{ github.run_number }}
ARG GITSHA1=${{ github.sha }}
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# ----------------------------------------------------------------------
# COMPILE REACT APP
# ----------------------------------------------------------------------
FROM node:18 AS frontend

FROM --platform=$BUILDPLATFORM node:18 AS frontend
WORKDIR /frontend

COPY scripts scripts/
Expand Down

0 comments on commit 91b2b82

Please sign in to comment.