Skip to content

Add build and push action #3

Add build and push action

Add build and push action #3

name: Build and push to GHCR
on:
push:
branches:
- deployment
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Create a 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@v3
- name: Setup Docker BuildX
uses: docker/setup-buildx-action@v2
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: true
cache-from: type=repository,ref=ghcr.io/python-discord/logviewer:latest
cache-to: type=inline
tags: |
ghcr.io/python-discord/logviewer:latest
ghcr.io/python-discord/logviewer:${{ steps.sha_tag.outputs.tag }}