From 2a2cb6187f1d225a1881bc7406649a3147d4a0a8 Mon Sep 17 00:00:00 2001 From: Giovanni Toraldo Date: Wed, 11 Dec 2024 17:54:46 +0100 Subject: [PATCH] add basic updatecli workflow --- .github/updatecli.tpl | 34 ++++++++++++++++ .github/workflows/bumpVersions.yml | 63 ++++++++++++++++++++++++++++++ repository/artifacts-23.yaml | 4 ++ repository/artifacts-73.yaml | 4 ++ repository/artifacts-74.yaml | 4 ++ 5 files changed, 109 insertions(+) create mode 100644 .github/updatecli.tpl create mode 100644 .github/workflows/bumpVersions.yml diff --git a/.github/updatecli.tpl b/.github/updatecli.tpl new file mode 100644 index 00000000..673a3ec5 --- /dev/null +++ b/.github/updatecli.tpl @@ -0,0 +1,34 @@ +name: Update Artifacts for {{ .updatecli_matrix_version }} version using reusable matrix + +sources: +{{- range $key, $artifact := .artifacts }} + {{- if $artifact.updatecli_matrix_target }} + src_{{ $key }}: + name: {{ $artifact.name }} + kind: maven + spec: + repository: {{ requiredEnv "NEXUS_USERNAME" }}:{{ requiredEnv "NEXUS_PASSWORD" }}@nexus.alfresco.com/nexus/repository/{{ $artifact.repository }} + groupid: {{ $artifact.group }} + artifactid: {{ $artifact.name}} + {{- $matrix_filter := index $ "matrix" $.updatecli_matrix_version $artifact.updatecli_matrix_target }} + {{- if $matrix_filter }} + versionFilter: + kind: regex + pattern: >- + ^{{ index $matrix_filter "version" }}{{ index $matrix_filter "pattern" }}$ + {{- end }} + {{- end }} +{{- end }} + +targets: +{{- range $key, $artifact := .artifacts }} + {{- if $artifact.updatecli_matrix_target }} + yml_{{ $key }}: + name: {{ $artifact.name }} yml + kind: yaml + sourceid: src_{{ $key }} + spec: + file: "{{ $.updatecli_self }}" + key: "artifacts.{{ $key }}.version" + {{- end }} +{{- end }} diff --git a/.github/workflows/bumpVersions.yml b/.github/workflows/bumpVersions.yml new file mode 100644 index 00000000..f15683d9 --- /dev/null +++ b/.github/workflows/bumpVersions.yml @@ -0,0 +1,63 @@ +--- +name: Bump versions +run-name: Bump using alfresco-updatecli/${{ inputs.alfresco-updatecli-ref || 'master' }} + +on: + pull_request: + branches: + - main + paths: + - .github/workflows/bumpVersions.yml + - .github/updatecli.tpl + workflow_dispatch: + inputs: + alfresco-updatecli-ref: + description: "The version to use for alfresco/alfresco-updatecli configs" + type: string + default: master + +env: + DEFAULT_BRANCH_NAME: main + +jobs: + build: + runs-on: ubuntu-latest + name: Bump versions + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + ref: ${{ github.head_ref || github.ref_name }} + token: ${{ secrets.BOT_GITHUB_TOKEN }} + + - name: Install Updatecli + uses: updatecli/updatecli-action@704a64517239e0993c5e3bf6749a063b8f950d9f # v2.70.0 + + - name: Checkout updatecli configs + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + repository: alfresco/alfresco-updatecli + ref: ${{ inputs.alfresco-updatecli-ref || 'master' }} + path: alfresco-updatecli + + - name: Build manifest and run Updatecli pipelines + shell: bash + run: | + for i in */artifacts-*.yaml; do + updatecli apply -c .github/updatecli.tpl -v ./${i} -v alfresco-updatecli/deployments/values/supported-matrix.yaml + done + env: + NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }} + NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} + UPDATECLI_GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} + + - name: Git Auto Commit + uses: stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842 # v5.0.1 + with: + commit_message: | + 🛠 Updatecli pipeline artifacts bump + commit_user_name: ${{ vars.BOT_GITHUB_USERNAME }} + commit_user_email: ${{ vars.BOT_GITHUB_EMAIL }} + branch: ${{ github.ref_name == env.DEFAULT_BRANCH_NAME && 'updatecli-bump-versions' || github.head_ref || github.ref_name }} + create_branch: ${{ github.ref_name == env.DEFAULT_BRANCH_NAME }} + push_options: ${{ github.ref_name == env.DEFAULT_BRANCH_NAME && '--force' || '' }} diff --git a/repository/artifacts-23.yaml b/repository/artifacts-23.yaml index 2875978c..e0bb3c6f 100644 --- a/repository/artifacts-23.yaml +++ b/repository/artifacts-23.yaml @@ -1,4 +1,6 @@ --- +updatecli_self: repository/artifacts-23.yaml +updatecli_matrix_version: current artifacts: postgresql: name: postgresql @@ -42,6 +44,7 @@ artifacts: classifier: ".zip" group: org.alfresco repository: enterprise-releases + updatecli_matrix_target: acs alfresco-content-services-community-distribution: name: alfresco-content-services-community-distribution version: 23.3.0 @@ -49,3 +52,4 @@ artifacts: classifier: ".zip" group: org.alfresco repository: public + updatecli_matrix_target: acs diff --git a/repository/artifacts-73.yaml b/repository/artifacts-73.yaml index 75503434..e133cd51 100644 --- a/repository/artifacts-73.yaml +++ b/repository/artifacts-73.yaml @@ -1,4 +1,6 @@ --- +updatecli_self: repository/artifacts-73.yaml +updatecli_matrix_version: 7.3.N artifacts: postgresql: name: postgresql @@ -42,6 +44,7 @@ artifacts: classifier: ".zip" group: org.alfresco repository: enterprise-releases + updatecli_matrix_target: acs alfresco-content-services-community-distribution: name: alfresco-content-services-community-distribution version: 7.3.2 @@ -49,3 +52,4 @@ artifacts: classifier: ".zip" group: org.alfresco repository: public + updatecli_matrix_target: acs diff --git a/repository/artifacts-74.yaml b/repository/artifacts-74.yaml index 4458552f..a696f6b2 100644 --- a/repository/artifacts-74.yaml +++ b/repository/artifacts-74.yaml @@ -1,4 +1,6 @@ --- +updatecli_self: repository/artifacts-74.yaml +updatecli_matrix_version: 7.4.N artifacts: postgresql: name: postgresql @@ -42,6 +44,7 @@ artifacts: classifier: ".zip" group: org.alfresco repository: enterprise-releases + updatecli_matrix_target: acs alfresco-content-services-community-distribution: name: alfresco-content-services-community-distribution version: 7.4.2 @@ -49,3 +52,4 @@ artifacts: classifier: ".zip" group: org.alfresco repository: public + updatecli_matrix_target: acs