Skip to content

Commit

Permalink
feat: add gh-action to publish docker image
Browse files Browse the repository at this point in the history
This Action Publishes a Docker image of the project to the Github Container Registry for the repo.
Also does neat tagging with versions :)

chore: shift publish workflow to proper directory

chore: fix label in Dockerfile
  • Loading branch information
Vyvy-vi committed Aug 8, 2021
1 parent e2dcbeb commit 7b143ae
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
github-token: ${{ secrets.ACCESS_TOKEN }}
version-file: './pyproject.toml'
version-path: 'tool.poetry.version'
fallback-version: "0.0.1"
release-count: 0
output-file: 'CHANGELOG.md'

- name: Create Release
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish Docker image
on:
workflow_dispatch:
release:
types: [published]

jobs:
push_to_registry:
name: Push Docker image to GitHub Packages
runs-on: ubuntu-latest
steps:
- name: check out the repo
uses: actions/checkout@v2
- name: get project version
id: get_version
run: |
echo ::set-output name=version_tag::$(awk -F'[ ="]+' '$1 == "version" { print $2 }' pyproject.toml)
echo "project version - v${{ steps.get_version.outputs.version_tag }}"
- name: version dockerfile
run: sed -i 's/v0.0.0/v${{ steps.get_version.outputs.version_tag}}/g' Dockerfile
- name: set up Docker builder
uses: docker/setup-buildx-action@v1
- name: log into GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: push to Github Container Registry
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: |
ghcr.io/heptagram-bot/api:v${{ steps.get_version.outputs.version_tag}}
ghcr.io/heptagram-bot/api:latest
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1

FROM python:3.8-slim-buster
LABEL org.opencontainers.image.source https://github.com/Heptagram-Bot/api
LABEL org.opencontainers.image.source https://github.com/heptagram-bot/api

# Setup env
ENV LANG C.UTF-8
Expand Down

0 comments on commit 7b143ae

Please sign in to comment.