Add forgejo actions #1356

Merged
mwalbeck merged 1 commit from actions into main 2025-02-15 12:19:20 +00:00
4 changed files with 300 additions and 494 deletions

View file

@ -1,123 +0,0 @@
def main(ctx):
return [
lint(),
test("3-9", "3.9"),
test("3-10", "3.10"),
test("3-11", "3.11"),
test("3-12", "3.12"),
test("3-13", "3.13"),
release("3-9", "3.9"),
release("3-10", "3.10"),
release("3-11", "3.11"),
release("3-12", "3.12"),
release("3-13", "3.13", custom_tags = "latest"),
]
def lint():
return {
"kind": "pipeline",
"type": "docker",
"name": "lint",
"steps": [
{
"name": "Lint Dockerfiles",
"image": "hadolint/hadolint:latest-debian",
"pull": "if-not-exists",
"commands": [
"hadolint --version",
"hadolint */Dockerfile",
],
},
],
"trigger": {
"event": [
"pull_request",
"push",
],
"ref": {
"exclude": [
"refs/heads/renovate/*",
],
},
},
}
def test(name, python_version, dockerfile = "Dockerfile"):
return {
"kind": "pipeline",
"type": "docker",
"name": "test_%s" % name,
"steps": [
{
"name": "build test",
"image": "plugins/docker",
"pull": "if-not-exists",
"settings": {
"dockerfile": "%s/%s" % (python_version, dockerfile),
"username": {
"from_secret": "dockerhub_username",
},
"password": {
"from_secret": "dockerhub_password_ro",
},
"dry_run": "true",
"repo": "mwalbeck/python-poetry",
},
},
],
"trigger": {
"event": [
"pull_request",
],
},
"depends_on": [
"lint",
],
}
def release(name, python_version, dockerfile = "Dockerfile", custom_tags = ""):
return {
"kind": "pipeline",
"type": "docker",
"name": "release_%s" % name,
"steps": [
{
"name": "determine tags",
"image": "mwalbeck/determine-docker-tags",
"pull": "if-not-exists",
"environment": {
"VERSION_TYPE": "docker_env",
"APP_NAME": "POETRY",
"DOCKERFILE_PATH": "%s/%s" % (python_version, dockerfile),
"APP_ENV": python_version,
"CUSTOM_TAGS": custom_tags,
},
},
{
"name": "build and publish",
"image": "plugins/docker",
"pull": "if-not-exists",
"settings": {
"dockerfile": "%s/%s" % (python_version, dockerfile),
"username": {
"from_secret": "dockerhub_username",
},
"password": {
"from_secret": "dockerhub_password",
},
"repo": "mwalbeck/python-poetry",
},
},
],
"trigger": {
"branch": [
"master",
],
"event": [
"push",
],
},
"depends_on": [
"lint",
],
}

View file

@ -1,371 +0,0 @@
---
kind: pipeline
type: docker
name: lint
platform:
os: linux
arch: amd64
steps:
- name: Lint Dockerfiles
pull: if-not-exists
image: hadolint/hadolint:latest-debian
commands:
- hadolint --version
- hadolint */Dockerfile
trigger:
event:
- pull_request
- push
ref:
exclude:
- refs/heads/renovate/*
---
kind: pipeline
type: docker
name: test_3-9
platform:
os: linux
arch: amd64
steps:
- name: build test
pull: if-not-exists
image: plugins/docker
settings:
dockerfile: 3.9/Dockerfile
dry_run: true
password:
from_secret: dockerhub_password_ro
repo: mwalbeck/python-poetry
username:
from_secret: dockerhub_username
trigger:
event:
- pull_request
depends_on:
- lint
---
kind: pipeline
type: docker
name: test_3-10
platform:
os: linux
arch: amd64
steps:
- name: build test
pull: if-not-exists
image: plugins/docker
settings:
dockerfile: 3.10/Dockerfile
dry_run: true
password:
from_secret: dockerhub_password_ro
repo: mwalbeck/python-poetry
username:
from_secret: dockerhub_username
trigger:
event:
- pull_request
depends_on:
- lint
---
kind: pipeline
type: docker
name: test_3-11
platform:
os: linux
arch: amd64
steps:
- name: build test
pull: if-not-exists
image: plugins/docker
settings:
dockerfile: 3.11/Dockerfile
dry_run: true
password:
from_secret: dockerhub_password_ro
repo: mwalbeck/python-poetry
username:
from_secret: dockerhub_username
trigger:
event:
- pull_request
depends_on:
- lint
---
kind: pipeline
type: docker
name: test_3-12
platform:
os: linux
arch: amd64
steps:
- name: build test
pull: if-not-exists
image: plugins/docker
settings:
dockerfile: 3.12/Dockerfile
dry_run: true
password:
from_secret: dockerhub_password_ro
repo: mwalbeck/python-poetry
username:
from_secret: dockerhub_username
trigger:
event:
- pull_request
depends_on:
- lint
---
kind: pipeline
type: docker
name: test_3-13
platform:
os: linux
arch: amd64
steps:
- name: build test
pull: if-not-exists
image: plugins/docker
settings:
dockerfile: 3.13/Dockerfile
dry_run: true
password:
from_secret: dockerhub_password_ro
repo: mwalbeck/python-poetry
username:
from_secret: dockerhub_username
trigger:
event:
- pull_request
depends_on:
- lint
---
kind: pipeline
type: docker
name: release_3-9
platform:
os: linux
arch: amd64
steps:
- name: determine tags
pull: if-not-exists
image: mwalbeck/determine-docker-tags
environment:
APP_ENV: 3.9
APP_NAME: POETRY
DOCKERFILE_PATH: 3.9/Dockerfile
VERSION_TYPE: docker_env
- name: build and publish
pull: if-not-exists
image: plugins/docker
settings:
dockerfile: 3.9/Dockerfile
password:
from_secret: dockerhub_password
repo: mwalbeck/python-poetry
username:
from_secret: dockerhub_username
trigger:
branch:
- master
event:
- push
depends_on:
- lint
---
kind: pipeline
type: docker
name: release_3-10
platform:
os: linux
arch: amd64
steps:
- name: determine tags
pull: if-not-exists
image: mwalbeck/determine-docker-tags
environment:
APP_ENV: 3.10
APP_NAME: POETRY
DOCKERFILE_PATH: 3.10/Dockerfile
VERSION_TYPE: docker_env
- name: build and publish
pull: if-not-exists
image: plugins/docker
settings:
dockerfile: 3.10/Dockerfile
password:
from_secret: dockerhub_password
repo: mwalbeck/python-poetry
username:
from_secret: dockerhub_username
trigger:
branch:
- master
event:
- push
depends_on:
- lint
---
kind: pipeline
type: docker
name: release_3-11
platform:
os: linux
arch: amd64
steps:
- name: determine tags
pull: if-not-exists
image: mwalbeck/determine-docker-tags
environment:
APP_ENV: 3.11
APP_NAME: POETRY
DOCKERFILE_PATH: 3.11/Dockerfile
VERSION_TYPE: docker_env
- name: build and publish
pull: if-not-exists
image: plugins/docker
settings:
dockerfile: 3.11/Dockerfile
password:
from_secret: dockerhub_password
repo: mwalbeck/python-poetry
username:
from_secret: dockerhub_username
trigger:
branch:
- master
event:
- push
depends_on:
- lint
---
kind: pipeline
type: docker
name: release_3-12
platform:
os: linux
arch: amd64
steps:
- name: determine tags
pull: if-not-exists
image: mwalbeck/determine-docker-tags
environment:
APP_ENV: 3.12
APP_NAME: POETRY
DOCKERFILE_PATH: 3.12/Dockerfile
VERSION_TYPE: docker_env
- name: build and publish
pull: if-not-exists
image: plugins/docker
settings:
dockerfile: 3.12/Dockerfile
password:
from_secret: dockerhub_password
repo: mwalbeck/python-poetry
username:
from_secret: dockerhub_username
trigger:
branch:
- master
event:
- push
depends_on:
- lint
---
kind: pipeline
type: docker
name: release_3-13
platform:
os: linux
arch: amd64
steps:
- name: determine tags
pull: if-not-exists
image: mwalbeck/determine-docker-tags
environment:
APP_ENV: 3.13
APP_NAME: POETRY
CUSTOM_TAGS: latest
DOCKERFILE_PATH: 3.13/Dockerfile
VERSION_TYPE: docker_env
- name: build and publish
pull: if-not-exists
image: plugins/docker
settings:
dockerfile: 3.13/Dockerfile
password:
from_secret: dockerhub_password
repo: mwalbeck/python-poetry
username:
from_secret: dockerhub_username
trigger:
branch:
- master
event:
- push
depends_on:
- lint
---
kind: signature
hmac: 29f7310f8d7d18bed0930ab5d9cfcb4528ee04cf497583a7c1559ddb0aaa2d1d
...

View file

@ -0,0 +1,166 @@
name: Build and publish
on:
push:
branches:
- main
jobs:
lint:
runs-on: docker
steps:
- uses: actions/checkout@v4
- uses: https://github.com/hadolint/hadolint-action@v3.1.0
with:
dockerfile: Dockerfile
recursive: true
python3_9:
runs-on: dind
steps:
- uses: actions/checkout@v4
- name: Get docker tags
id: tags
shell: sh
env:
VERSION_TYPE: "docker_env"
APP_NAME: "POETRY"
APP_ENV: "3.9"
DOCKERFILE_PATH: "3.9/Dockerfile"
IMAGE_NAME: "mwalbeck/python-poetry"
run: |
determine-docker-tags
dockerd &
- name: Login to Docker Hub
uses: https://github.com/docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: https://github.com/docker/setup-buildx-action@v3
- name: Build and push
uses: https://github.com/docker/build-push-action@v6
with:
push: true
tags: ${{ steps.tags.outputs.tags }}
file: "3.9/Dockerfile"
python3_10:
runs-on: dind
steps:
- uses: actions/checkout@v4
- name: Get docker tags
id: tags
shell: sh
env:
VERSION_TYPE: "docker_env"
APP_NAME: "POETRY"
APP_ENV: "3.10"
DOCKERFILE_PATH: "3.10/Dockerfile"
IMAGE_NAME: "mwalbeck/python-poetry"
run: |
determine-docker-tags
dockerd &
- name: Login to Docker Hub
uses: https://github.com/docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: https://github.com/docker/setup-buildx-action@v3
- name: Build and push
uses: https://github.com/docker/build-push-action@v6
with:
push: true
tags: ${{ steps.tags.outputs.tags }}
file: "3.10/Dockerfile"
python3_11:
runs-on: dind
steps:
- uses: actions/checkout@v4
- name: Get docker tags
id: tags
shell: sh
env:
VERSION_TYPE: "docker_env"
APP_NAME: "POETRY"
APP_ENV: "3.11"
DOCKERFILE_PATH: "3.11/Dockerfile"
IMAGE_NAME: "mwalbeck/python-poetry"
run: |
determine-docker-tags
dockerd &
- name: Login to Docker Hub
uses: https://github.com/docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: https://github.com/docker/setup-buildx-action@v3
- name: Build and push
uses: https://github.com/docker/build-push-action@v6
with:
push: true
tags: ${{ steps.tags.outputs.tags }}
file: "3.11/Dockerfile"
python3_12:
runs-on: dind
steps:
- uses: actions/checkout@v4
- name: Get docker tags
id: tags
shell: sh
env:
VERSION_TYPE: "docker_env"
APP_NAME: "POETRY"
APP_ENV: "3.12"
DOCKERFILE_PATH: "3.12/Dockerfile"
IMAGE_NAME: "mwalbeck/python-poetry"
run: |
determine-docker-tags
dockerd &
- name: Login to Docker Hub
uses: https://github.com/docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: https://github.com/docker/setup-buildx-action@v3
- name: Build and push
uses: https://github.com/docker/build-push-action@v6
with:
push: true
tags: ${{ steps.tags.outputs.tags }}
file: "3.12/Dockerfile"
python3_13:
runs-on: dind
steps:
- uses: actions/checkout@v4
- name: Get docker tags
id: tags
shell: sh
env:
VERSION_TYPE: "docker_env"
APP_NAME: "POETRY"
APP_ENV: "3.13"
DOCKERFILE_PATH: "3.13/Dockerfile"
IMAGE_NAME: "mwalbeck/python-poetry"
run: |
determine-docker-tags
dockerd &
- name: Login to Docker Hub
uses: https://github.com/docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: https://github.com/docker/setup-buildx-action@v3
- name: Build and push
uses: https://github.com/docker/build-push-action@v6
with:
push: true
tags: ${{ steps.tags.outputs.tags }}
file: "3.13/Dockerfile"

134
.forgejo/workflows/test.yml Normal file
View file

@ -0,0 +1,134 @@
name: Test
on: pull_request
jobs:
lint:
if: github.ref != 'refs/heads/renovate/*'
runs-on: docker
steps:
- uses: actions/checkout@v4
- uses: https://github.com/hadolint/hadolint-action@v3.1.0
with:
dockerfile: Dockerfile
recursive: true
python3_9:
runs-on: dind
steps:
- uses: actions/checkout@v4
- name: Get docker tags
id: tags
shell: sh
env:
VERSION_TYPE: "docker_env"
APP_NAME: "POETRY"
APP_ENV: "3.9"
DOCKERFILE_PATH: "3.9/Dockerfile"
IMAGE_NAME: "mwalbeck/python-poetry"
run: |
determine-docker-tags
dockerd &
- name: Set up Docker Buildx
uses: https://github.com/docker/setup-buildx-action@v3
- name: Test build
uses: https://github.com/docker/build-push-action@v6
with:
tags: ${{ steps.tags.outputs.tags }}
file: "3.9/Dockerfile"
python3_10:
runs-on: dind
steps:
- uses: actions/checkout@v4
- name: Get docker tags
id: tags
shell: sh
env:
VERSION_TYPE: "docker_env"
APP_NAME: "POETRY"
APP_ENV: "3.10"
DOCKERFILE_PATH: "3.10/Dockerfile"
IMAGE_NAME: "mwalbeck/python-poetry"
run: |
determine-docker-tags
dockerd &
- name: Set up Docker Buildx
uses: https://github.com/docker/setup-buildx-action@v3
- name: Test build
uses: https://github.com/docker/build-push-action@v6
with:
tags: ${{ steps.tags.outputs.tags }}
file: "3.10/Dockerfile"
python3_11:
runs-on: dind
steps:
- uses: actions/checkout@v4
- name: Get docker tags
id: tags
shell: sh
env:
VERSION_TYPE: "docker_env"
APP_NAME: "POETRY"
APP_ENV: "3.11"
DOCKERFILE_PATH: "3.11/Dockerfile"
IMAGE_NAME: "mwalbeck/python-poetry"
run: |
determine-docker-tags
dockerd &
- name: Set up Docker Buildx
uses: https://github.com/docker/setup-buildx-action@v3
- name: Test build
uses: https://github.com/docker/build-push-action@v6
with:
tags: ${{ steps.tags.outputs.tags }}
file: "3.11/Dockerfile"
python3_12:
runs-on: dind
steps:
- uses: actions/checkout@v4
- name: Get docker tags
id: tags
shell: sh
env:
VERSION_TYPE: "docker_env"
APP_NAME: "POETRY"
APP_ENV: "3.12"
DOCKERFILE_PATH: "3.12/Dockerfile"
IMAGE_NAME: "mwalbeck/python-poetry"
run: |
determine-docker-tags
dockerd &
- name: Set up Docker Buildx
uses: https://github.com/docker/setup-buildx-action@v3
- name: Test build
uses: https://github.com/docker/build-push-action@v6
with:
tags: ${{ steps.tags.outputs.tags }}
file: "3.12/Dockerfile"
python3_13:
runs-on: dind
steps:
- uses: actions/checkout@v4
- name: Get docker tags
id: tags
shell: sh
env:
VERSION_TYPE: "docker_env"
APP_NAME: "POETRY"
APP_ENV: "3.13"
DOCKERFILE_PATH: "3.13/Dockerfile"
IMAGE_NAME: "mwalbeck/python-poetry"
run: |
determine-docker-tags
dockerd &
- name: Set up Docker Buildx
uses: https://github.com/docker/setup-buildx-action@v3
- name: Test build
uses: https://github.com/docker/build-push-action@v6
with:
tags: ${{ steps.tags.outputs.tags }}
file: "3.13/Dockerfile"