Skip to content

Commit 2ebb43d

Browse files
committed
👷 CI
1 parent 857f83d commit 2ebb43d

File tree

5 files changed

+127
-65
lines changed

5 files changed

+127
-65
lines changed

.github/workflows/CI-CD.yaml

Lines changed: 7 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,17 @@
1-
#file: noinspection SpellCheckingInspection
1+
name: CI/CD
2+
23
on:
34
push:
45
branches: [ "main", "dev" ]
5-
# Publish semver tags as releases.
66
tags: [ 'v*.*.*' ]
77
pull_request:
8-
branches: ["dev"]
9-
10-
env:
11-
REGISTRY: ghcr.io
12-
IMAGE_NAME: ${{ github.repository }}
8+
branches: [ "dev" ]
139

1410
jobs:
1511
tests:
16-
name: Run tests
17-
runs-on: ubuntu-latest
18-
steps:
19-
- uses: actions/checkout@v4
20-
- name: Setup PDM
21-
uses: pdm-project/setup-pdm@v4
22-
with:
23-
cache: true
24-
- name: Install dependencies
25-
run: pdm install -d
26-
- name: Run linting check
27-
run: pdm run lint --check
28-
- name: Run tests
29-
run: pdm run tests
30-
- name: Export requirements
31-
run: pdm run export
32-
- name: Check for changes
33-
if: contains(github.actor, 'renovate[bot]') == false
34-
run: git diff --exit-code HEAD requirements.txt
12+
uses: ./.github/workflows/tests.yaml
13+
3514
docker:
3615
needs: tests
37-
runs-on: ubuntu-latest
38-
permissions:
39-
contents: read
40-
packages: write
41-
id-token: write
42-
steps:
43-
- name: Checkout repository
44-
uses: actions/checkout@v4
45-
46-
- name: Set up Docker Buildx
47-
uses: docker/setup-buildx-action@v3.6.1
48-
49-
- name: Log into registry ${{ env.REGISTRY }}
50-
uses: docker/login-action@v3.3.0
51-
with:
52-
registry: ${{ env.REGISTRY }}
53-
username: ${{ github.actor }}
54-
password: ${{ secrets.GITHUB_TOKEN }}
55-
56-
- name: Extract Docker metadata for
57-
id: meta
58-
uses: docker/metadata-action@v5.5.1
59-
with:
60-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
61-
tags: |
62-
type=ref,event=branch
63-
type=ref,event=pr
64-
type=ref,event=tag
65-
type=sha
66-
67-
- name: Build and push Docker image
68-
uses: docker/build-push-action@v6.6.1
69-
with:
70-
context: .
71-
push: true
72-
tags: ${{ steps.meta.outputs.tags }}
73-
labels: ${{ steps.meta.outputs.labels }}
74-
cache-from: type=gha
75-
cache-to: type=gha,mode=max
16+
uses: ./.github/workflows/docker.yaml
17+
secrets: inherit

.github/workflows/docker.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches: [ "main", "dev" ]
6+
tags: [ 'v*.*.*' ]
7+
pull_request:
8+
branches: ["dev"]
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
docker:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
id-token: write
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3.3.0
27+
28+
- name: Log into registry ${{ env.REGISTRY }}
29+
uses: docker/login-action@v3.2.0
30+
with:
31+
registry: ${{ env.REGISTRY }}
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Extract Docker metadata
36+
id: meta
37+
uses: docker/metadata-action@v5.5.1
38+
with:
39+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
40+
tags: |
41+
type=ref,event=branch
42+
type=ref,event=pr
43+
type=ref,event=tag
44+
type=sha
45+
46+
- name: Build and push Docker image
47+
uses: docker/build-push-action@v6.1.0
48+
with:
49+
context: .
50+
push: true
51+
tags: ${{ steps.meta.outputs.tags }}
52+
labels: ${{ steps.meta.outputs.labels }}
53+
cache-from: type=gha
54+
cache-to: type=gha,mode=max

.github/workflows/test.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Run Tests
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
run-tests:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Setup PDM
12+
uses: pdm-project/setup-pdm@v4
13+
with:
14+
cache: true
15+
- name: Install dependencies
16+
run: pdm install -d
17+
- name: Run linting check
18+
run: pdm run lint --check
19+
- name: Run tests
20+
run: pdm run tests
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Update Dependencies
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * 0' # Runs at 00:00 every Sunday
6+
workflow_dispatch: # Allows manual triggering
7+
8+
jobs:
9+
update-dependencies:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Setup PDM
17+
uses: pdm-project/setup-pdm@v4
18+
with:
19+
cache: true
20+
- name: Update dependencies
21+
run: pdm update
22+
- name: Export requirements
23+
run: pdm export -o requirements.txt
24+
- name: Check for changes
25+
id: git-check
26+
run: |
27+
git diff --exit-code --quiet requirements.txt || echo "changed=true" >> $GITHUB_OUTPUT
28+
- name: Create Pull Request
29+
if: steps.git-check.outputs.changed == 'true'
30+
run: |
31+
git config user.name github-actions
32+
git config user.email github-actions@github.com
33+
git checkout -b update-dependencies-${{ github.run_id }}
34+
git add requirements.txt
35+
git commit -m "Update dependencies"
36+
git push origin update-dependencies-${{ github.run_id }}
37+
gh pr create --title "Update dependencies" --body "This PR updates the project dependencies. Please review the changes and merge if everything looks good." --base ${{ github.ref_name }} --head update-dependencies-${{ github.run_id }}
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

renovate.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
"labels": [
1010
"deps"
1111
],
12+
"ignorePaths": [
13+
"requirements.txt"
14+
],
1215
"commitMessagePrefix": "⬆️",
1316
"commitMessageAction": "Upgrade",
1417
"packageRules": [
@@ -25,6 +28,10 @@
2528
],
2629
"commitMessagePrefix": "⬇️",
2730
"commitMessageAction": "Downgrade"
31+
},
32+
{
33+
"matchDatasources": ["pypi"],
34+
"addLabels": ["pypi"]
2835
}
2936
]
3037
}

0 commit comments

Comments
 (0)