Skip to content

Build Docker image and push to GHCR #2

Build Docker image and push to GHCR

Build Docker image and push to GHCR #2

Workflow file for this run

name: Build Docker image and push to GHCR
on:
# Enable manual launching
workflow_dispatch:
# Run when we push to main and have changed the Go code or Dockerfile
push:
branches:
- main
paths:
- "**/*.go"
- "Dockerfile"
- "go.*"
# Run at 00:00 every Monday to catch base image upgrades
schedule:
- cron: "0 0 * * 1"
env:
DOCKER_IMAGE: ghcr.io/${{ github.repository }}/adder:latest
jobs:
build-push-image:
runs-on: ubuntu-latest
# Turn on write permission for packages so we can push to GHCR
permissions:
contents: read
packages: write
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }} # Username of whoever kicked off this job
password: ${{ secrets.GITHUB_TOKEN }} # Token for the permissions given to this runner
- name: Build and push image
uses: docker/build-push-action@v5
with:
tags: ${{ env.DOCKER_IMAGE }}
build-args: "GO_VERSION=${{ vars.GO_VERSION }}"
push: true