Skip to content

Build and deploy a Docker image #160

Build and deploy a Docker image

Build and deploy a Docker image #160

Workflow file for this run

name: Build and deploy a Docker image
on:
workflow_run:
workflows: ["Linting"]
push:
branches:
- master
types:
- completed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push'
name: Build & Push to GHCR
runs-on: ubuntu-latest
steps:
- name: Create a short SHA tag
id: sha_tag
run: |
tag=$(cut -c 1-7 <<< $GITHUB_SHA)
echo "::set-output name=tag::$tag"
- name: Checkout code
uses: actions/checkout@v2
with:
path: friendo-bot
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to ghcr
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push to ghcr
uses: docker/build-push-action@v2
with:
context: friendo-bot/
file: friendo-bot/Dockerfile
push: true
cache-from: type=registry,ref=ghcr.io/fisher60/friendo-bot:latest
cache-to: type=inline
tags: |
ghcr.io/fisher60/friendo-bot:latest
ghcr.io/fisher60/friendo-bot:${{ steps.sha_tag.outputs.tag }}
build-args: |
git_sha=${{ github.sha }}