Skip to content

Commit

Permalink
Merge pull request #10 from dlcs/feature/gh_action
Browse files Browse the repository at this point in the history
Add githubaction to build image
  • Loading branch information
donaldgray authored Aug 18, 2022
2 parents 567f05c + 24ce34c commit b9efdfc
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build and push Appetiser docker image

on:
push:
branches:
- master
tags:
- "*"
pull_request:
jobs:
build-push:
runs-on: ubuntu-latest

steps:
- name: Extract branch name for push
run: echo "normalized_branch_name=$(stripped=${GITHUB_REF##*/} && echo ${stripped/\//-})" >> $GITHUB_ENV
if: github.event_name == 'push'

- name: Extract branch name for pull request
run: echo "normalized_branch_name=$(stripped=${PR_REF#refs/heads/} && echo ${stripped/\//-})" >> $GITHUB_ENV
if: github.event_name == 'pull_request'
env:
PR_REF: ${{ github.event.pull_request.head.ref }}

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

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Check out code
id: checkout
uses: actions/checkout@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: |
ghcr.io/dlcs/appetiser:${{ github.sha }}
ghcr.io/dlcs/appetiser:${{ env.normalized_branch_name }}

0 comments on commit b9efdfc

Please sign in to comment.