From 94f0dde6125c6f57b6faf99091a22be890615086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Fri, 15 Nov 2024 17:53:56 +0100 Subject: [PATCH 1/2] Migrate configuration from c2cciutils to tag-publish --- .github/publish.yaml | 5 +++++ ci/config.yaml | 6 ------ 2 files changed, 5 insertions(+), 6 deletions(-) create mode 100644 .github/publish.yaml delete mode 100644 ci/config.yaml diff --git a/.github/publish.yaml b/.github/publish.yaml new file mode 100644 index 0000000000..794c5a0d8c --- /dev/null +++ b/.github/publish.yaml @@ -0,0 +1,5 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/camptocamp/tag-publish/0.8.2/c2cciutils/schema.json + +docker: + images: + - name: camptocamp/github-app-geo-project diff --git a/ci/config.yaml b/ci/config.yaml deleted file mode 100644 index 9a0d4a904c..0000000000 --- a/ci/config.yaml +++ /dev/null @@ -1,6 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/camptocamp/c2cciutils/1.7.0/c2cciutils/schema.json - -publish: - docker: - images: - - name: camptocamp/github-app-geo-project From b3dc1593ca1e07f35d33f8c36325b4eb83a17951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Fri, 15 Nov 2024 18:40:11 +0100 Subject: [PATCH 2/2] Add support of tag-publish --- .github/publish.yaml | 7 +++++++ .github/workflows/main.yaml | 10 +++------- ci/requirements.txt | 2 +- github_app_geo_project/module/versions/__init__.py | 10 ++++++++-- tests/test_module_versions.py | 2 -- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.github/publish.yaml b/.github/publish.yaml index 794c5a0d8c..28c935fb92 100644 --- a/.github/publish.yaml +++ b/.github/publish.yaml @@ -1,5 +1,12 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/camptocamp/tag-publish/0.8.2/c2cciutils/schema.json docker: + repository: + github: + server: ghcr.io + versions: + - version_tag + - version_branch + - rebuild images: - name: camptocamp/github-app-geo-project diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index eb86651419..8c4410ee82 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -9,9 +9,11 @@ on: - '*' pull_request: +permissions: + contents: write + env: HAS_SECRETS: ${{ secrets.HAS_SECRETS }} - PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring jobs: main: @@ -26,12 +28,6 @@ jobs: with: fetch-depth: 0 - - uses: camptocamp/initialise-gopass-summon-action@v2 - with: - ci-gpg-private-key: ${{secrets.CI_GPG_PRIVATE_KEY}} - github-gopass-ci-token: ${{secrets.GOPASS_CI_GITHUB_TOKEN}} - patterns: pypi docker - # Use Python 3.11 - uses: actions/setup-python@v5 with: diff --git a/ci/requirements.txt b/ci/requirements.txt index b7a7fb69a0..1c50e683c1 100644 --- a/ci/requirements.txt +++ b/ci/requirements.txt @@ -11,4 +11,4 @@ setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerabil jinja2>=3.1.3 # not directly required, pinned by Snyk to avoid a vulnerability cryptography>=42.0.8 # not directly required, pinned by Snyk to avoid a vulnerability zipp>=3.19.1 # not directly required, pinned by Snyk to avoid a vulnerability -tag-publish==0.8.2 +tag-publish==0.9.1 diff --git a/github_app_geo_project/module/versions/__init__.py b/github_app_geo_project/module/versions/__init__.py index 41b87a70c7..11c6ad034c 100644 --- a/github_app_geo_project/module/versions/__init__.py +++ b/github_app_geo_project/module/versions/__init__.py @@ -16,6 +16,7 @@ import github import requests import security_md +import yaml from pydantic import BaseModel from github_app_geo_project import module, utils @@ -459,8 +460,13 @@ def _get_names( if match and match.group(1) not in names: names.append(match.group(1)) os.environ["GITHUB_REPOSITORY"] = f"{context.github_project.owner}/{context.github_project.repository}" - data = c2cciutils.get_config() - docker_config = data.get("publish", {}).get("docker", {}) + docker_config = {} + if os.path.exists(".github/publish.yaml"): + with open(".github/publish.yaml", encoding="utf-8") as file: + docker_config = yaml.load(file, Loader=yaml.SafeLoader).get("docker", {}) + else: + data = c2cciutils.get_config() + docker_config = data.get("publish", {}).get("docker", {}) if docker_config: names = names_by_datasource.setdefault("docker", _TransversalStatusNameByDatasource()).names all_versions = [version] diff --git a/tests/test_module_versions.py b/tests/test_module_versions.py index 2e7e8d2c5f..b1319f2d32 100644 --- a/tests/test_module_versions.py +++ b/tests/test_module_versions.py @@ -114,8 +114,6 @@ async def test_process_step_2() -> None: "docker": { "names": [ "ghcr.io/camptocamp/github-app-geo-project:master", - "camptocamp/github-app-geo-project:master", - "docker.io/camptocamp/github-app-geo-project:master", ], }, "github-release": {