Skip to content

Commit

Permalink
Added new workflows to start the main workflow and initially just bui…
Browse files Browse the repository at this point in the history
…ld the docker image
  • Loading branch information
sam-c-dfe committed Jan 23, 2024
1 parent d3f2f29 commit 4cc3933
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build Image and Publish to GCR

on:
workflow_call:
inputs:
branch:
type: string
required: true
checked-out-sha:
type: string
required: true

concurrency:
group: ${{ github.workflow }}-${{ github.event.inputs.environment }}
cancel-in-progress: true

env:
DOCKER_IMAGE: early-years-qualification
GITHUB_CONTAINER_REGISTRY: ghcr.io
ORG_NAME: dfe-digital

jobs:

build-image:

runs-on: ubuntu-22.04
name: Build & Publish Image

steps:

- name: Checkout Repository
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}

# - name: GitHub Container Registry Login
# uses: docker/login-action@v3
# with:
# registry: ${{ env.GITHUB_CONTAINER_REGISTRY }}
# username: ${{ github.repository_owner }}
# password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Image & Publish To GCR
uses: docker/build-push-action@v4
with:
context: ./
file: ./src/Dfe.EarlyYearsQualification.Web/Dockerfile
build-args: COMMIT_SHA=${{ inputs.checked-out-sha }}
tags: |
${{ env.GITHUB_CONTAINER_REGISTRY }}/${{ env.ORG_NAME }}/${{ env.DOCKER_IMAGE }}:${{ inputs.branch }}-${{ inputs.checked-out-sha }}
# push: true // Commented out for now to test the docker build
38 changes: 38 additions & 0 deletions .github/workflows/main-build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Main build & deploy

on:
workflow_dispatch:
push:
branches: ["main"]
paths:
- 'src/**'
- '.github/workflows/main-build-and-deploy.yml'

jobs:

set-env:
runs-on: ubuntu-22.04
name: Set Environment Values
outputs:
branch: ${{ steps.var.outputs.branch }}
checked-out-sha: ${{ steps.var.outputs.checked-out-sha }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.ref }}

- id: var
run: |
GIT_BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}
CHECKED_OUT_SHA="$(git log -1 '--format=format:%H')"
echo "branch=$GIT_BRANCH" >> $GITHUB_OUTPUT
echo "checked-out-sha=${CHECKED_OUT_SHA}" >> $GITHUB_OUTPUT
create-and-publish-image:
needs: set-env
name: Create & Publish Image
uses: ./.github/workflows/build-image.yml
secrets: inherit
with:
branch: ${{ needs.set-env.outputs.branch }}
checked-out-sha: ${{ needs.set-env.outputs.checked-out-sha }}

0 comments on commit 4cc3933

Please sign in to comment.