Skip to content

Commit

Permalink
ci: deploy to ghcr on push (#3435)
Browse files Browse the repository at this point in the history
publish and tag docker images continuously to ghcr.io. adds custom
tagging so we can retain every commit. it's technically possible to do
this on docker hub, but in order to have custom tags, you need to set up
a regular user and log in/push via that user. the authentication is much
cleaner in github actions for ghcr.

(note docker hub pulls for releases are still staying the same, this is
just an alternative form of retention going forward).
  • Loading branch information
charles-cooper authored May 19, 2023
1 parent 8a28372 commit 870ad49
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/ghcr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Deploy docker image to ghcr

# Deploy docker image to ghcr on pushes to master and all releases/tags.
# Note releases to docker hub are managed separately in another process
# (github sends webhooks to docker hub which triggers the build there).
# This workflow is an alternative form of retention for docker images
# which also allows us to tag and retain every single commit to master.

on:
push:
tags:
- '*'
branches:
- master
release:
types: [released]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
deploy-ghcr:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v3
with:
# need to fetch unshallow so that setuptools_scm can infer the version
fetch-depth: 0

- uses: actions/setup-python@v4
name: Install python
with:
python-version: "3.11"
cache: "pip"

- name: Generate vyper/version.py
run: |
pip install .
echo "VYPER_VERSION=$(PYTHONPATH=. python vyper/cli/vyper_compile.py --version)" >> "$GITHUB_ENV"
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=true
tags: |
type=ref,event=branch
type=ref,event=tag
type=raw,value=${{ env.VYPER_VERSION }}
- name: Login to ghcr.io
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 870ad49

Please sign in to comment.