Skip to content

Rebuild master docker image #79

Rebuild master docker image

Rebuild master docker image #79

Workflow file for this run

name: Rebuild master docker image
on:
workflow_dispatch:
schedule:
- cron: '0 12 * * 0'
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: set-up-environment
uses: DFE-Digital/github-actions/set-up-environment@master
- uses: Azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- uses: DfE-Digital/keyvault-yaml-secret@v1
id: keyvault-yaml-secret
with:
keyvault: ${{ secrets.KEY_VAULT}}
secret: INFRA-KEYS
key: SNYK-TOKEN,SLACK-WEBHOOK
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@master
- name: Set environment variables
run: |
GIT_REF=${{ github.ref }}
echo "GIT_BRANCH=${GIT_REF##*/}" >> $GITHUB_ENV
GIT_SHORT_SHA=$(echo "${{ github.sha }}" | cut -c -7)
echo "GIT_SHORT_SHA=${GIT_SHORT_SHA}" >> $GITHUB_ENV
- name: Login to GitHub Container Repository
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build docker image
uses: docker/build-push-action@v5
with:
cache-to: type=inline
tags: |
${{ env.DOCKER_REPOSITORY }}:master
push: false
load: true
build-args: |
APP_SHA=${{ env.GIT_SHORT_SHA }}
- name: Run Snyk to check Docker image for vulnerabilities
uses: snyk/actions/docker@master
env:
SNYK_TOKEN: ${{ steps.keyvault-yaml-secret.outputs.SNYK-TOKEN }}
with:
image: ${{ env.DOCKER_REPOSITORY }}:master
args: --severity-threshold=high --file=Dockerfile
- name: Push image to registry
if: ${{ success() }}
run: docker image push --all-tags ${{ env.DOCKER_REPOSITORY }}
- name: Slack Notification
if: failure() && github.ref == 'refs/heads/master'
uses: rtCamp/action-slack-notify@master
env:
SLACK_COLOR: ${{env.SLACK_ERROR}}
SLACK_TITLE: 'Failure Building Adviser'
SLACK_MESSAGE: 'There has been a failure building the teacher training adviser'
SLACK_WEBHOOK: ${{ steps.keyvault-yaml-secret.outputs.SLACK-WEBHOOK }}