Skip to content

Commit

Permalink
Merge pull request #923 from rwaffen/update_gha
Browse files Browse the repository at this point in the history
update gha
  • Loading branch information
rwaffen authored Sep 5, 2023
2 parents 2cb70a0 + 6baef08 commit 6084374
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 60 deletions.
62 changes: 4 additions & 58 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,67 +6,13 @@ on:
- "v*"

jobs:

build-and-push-image:

build-and-push-container:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get tags
shell: python
run: |
import re
from packaging.version import parse
version = "${{ github.ref }}".replace("refs/tags/v", "")
image = "ghcr.io/${{ github.repository }}"
tags = set()
# full version
tags.add(f"{image}:{version}")
if not parse(version).is_prerelease:
# only final and post-releases should get the tags
# used for automatic use of latest *stable* version
# major_version
major_version = re.search(r'(\d+?)\.', version).group(1)
tags.add(f"{image}:{major_version}")
# major_version.minor_version
major_and_minor_version = re.search(r'(\d+?\.\d+?)\.', version).group(1)
tags.add(f"{image}:{major_and_minor_version}")
tags.add(f"{image}:latest")
tags = ",".join(sorted(list(tags)))
print(f"::set-output name=tags::{tags}")
id: tags

- name: Build and push
uses: docker/build-push-action@v4
- uses: voxpupuli/gha-build-and-publish-a-container@v1
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.tags.outputs.tags }}
github_token: ${{ secrets.GITHUB_TOKEN }}
build_arch: linux/amd64,linux/arm64
18 changes: 16 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
python-version: [3.8, 3.9, '3.10', 3.11]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand All @@ -42,10 +42,24 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true

build_docker_image:
name: 'Test building a container'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Build Docker image
uses: docker/build-push-action@v4
with:
context: .
push: false

security-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
Expand Down

0 comments on commit 6084374

Please sign in to comment.