Skip to content

Commit b359c04

Browse files
authored
switch docker registry to ghcr (#27)
* switch docker registry to ghcr * move pre-commit and tests to the same workflow
1 parent 6f3b6cf commit b359c04

File tree

5 files changed

+88
-88
lines changed

5 files changed

+88
-88
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Docker Image Build
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
pull_request:
7+
branches: ["main"]
8+
9+
env:
10+
REGISTRY: ghcr.io
11+
IMAGE_NAME: ${{ github.repository }}
12+
13+
jobs:
14+
pre-commit:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v2
18+
- uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.10'
21+
- name: Run image
22+
uses: abatilo/actions-poetry@v2
23+
with:
24+
poetry-version: '1.3.2'
25+
- name: Install dependencies
26+
run: poetry install
27+
- name: Run pre-commit
28+
run: poetry run pre-commit run --all-files
29+
30+
test:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v3
34+
- uses: actions/setup-python@v4
35+
with:
36+
python-version: '3.10'
37+
- name: Run image
38+
uses: abatilo/actions-poetry@v2
39+
with:
40+
poetry-version: '1.3.2'
41+
- name: Install dependencies
42+
run: poetry install
43+
- name: Run tests
44+
run: poetry run pytest
45+
46+
build-and-push:
47+
permissions:
48+
contents: read
49+
packages: write
50+
runs-on: ubuntu-latest
51+
needs: [pre-commit, test]
52+
steps:
53+
- name: Checkout repo
54+
uses: actions/checkout@v3
55+
56+
# Set image tag to git tag, or commit hash for pull request
57+
- name: Set IMAGE_TAG
58+
run: |
59+
if [ "${{ github.event_name }}" == "push" ]; then
60+
echo "IMAGE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
61+
else
62+
echo "IMAGE_TAG=${{ github.sha }}" >> $GITHUB_ENV
63+
fi
64+
65+
- name: Log in to the Container registry
66+
uses: docker/login-action@v3
67+
with:
68+
registry: ${{ env.REGISTRY }}
69+
username: ${{ github.actor }}
70+
password: ${{ secrets.GITHUB_TOKEN }}
71+
72+
- name: Extract metadata (tags, labels) for Docker
73+
id: meta
74+
uses: docker/metadata-action@v5
75+
with:
76+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
77+
tags: |
78+
type=raw,value=${{ env.IMAGE_TAG }}
79+
type=raw,value=${{ github.sha }}
80+
81+
- name: Build and push Docker image
82+
uses: docker/build-push-action@v5
83+
with:
84+
context: .
85+
push: true
86+
tags: ${{ steps.meta.outputs.tags }}
87+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/image-push.yaml

Lines changed: 0 additions & 43 deletions
This file was deleted.

.github/workflows/poetry.yaml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/pre-commit.yaml

Lines changed: 0 additions & 23 deletions
This file was deleted.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "example-publisher"
3-
version = "1.1.0"
3+
version = "1.1.1"
44
description = ""
55
authors = []
66
license = "Apache-2"

0 commit comments

Comments
 (0)