Skip to content

Commit beca870

Browse files
authored
switch docker registry to ghcr (#61)
1 parent f1c7b72 commit beca870

File tree

3 files changed

+72
-58
lines changed

3 files changed

+72
-58
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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: ./.github/actions/python-poetry
19+
- uses: pre-commit/action@v2.0.3
20+
21+
run-tests:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v2
25+
- uses: ./.github/actions/python-poetry
26+
- run: poetry run pytest
27+
env:
28+
TEST_MODE: "1"
29+
30+
build-and-push:
31+
permissions:
32+
contents: read
33+
packages: write
34+
runs-on: ubuntu-latest
35+
needs: [pre-commit, run-tests]
36+
steps:
37+
- name: Checkout repo
38+
uses: actions/checkout@v3
39+
40+
# Set image tag to git tag, or commit hash for pull request
41+
- name: Set IMAGE_TAG
42+
run: |
43+
if [ "${{ github.event_name }}" == "push" ]; then
44+
echo "IMAGE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
45+
else
46+
echo "IMAGE_TAG=${{ github.sha }}" >> $GITHUB_ENV
47+
fi
48+
49+
- name: Log in to the Container registry
50+
uses: docker/login-action@v3
51+
with:
52+
registry: ${{ env.REGISTRY }}
53+
username: ${{ github.actor }}
54+
password: ${{ secrets.GITHUB_TOKEN }}
55+
56+
- name: Extract metadata (tags, labels) for Docker
57+
id: meta
58+
uses: docker/metadata-action@v5
59+
with:
60+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
61+
tags: |
62+
type=raw,value=${{ env.IMAGE_TAG }}
63+
type=raw,value=${{ github.sha }}
64+
65+
- name: Build and push Docker image
66+
uses: docker/build-push-action@v5
67+
with:
68+
context: .
69+
push: true
70+
tags: ${{ steps.meta.outputs.tags }}
71+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/ci.yaml

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

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ignore_missing_imports = true
44

55
[tool.poetry]
66
name = "pyth-observer"
7-
version = "0.1.14"
7+
version = "0.1.15"
88
description = "Alerts and stuff"
99
authors = []
1010
readme = "README.md"

0 commit comments

Comments
 (0)