From 6599cd145a217dcda1cb36b1c21609ae06f5a828 Mon Sep 17 00:00:00 2001 From: KB-perByte Date: Fri, 26 May 2023 14:43:15 +0530 Subject: [PATCH 1/5] push workflow added as common --- .github/workflows/push_network.yml | 108 +++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 .github/workflows/push_network.yml diff --git a/.github/workflows/push_network.yml b/.github/workflows/push_network.yml new file mode 100644 index 0000000..50cb17c --- /dev/null +++ b/.github/workflows/push_network.yml @@ -0,0 +1,108 @@ +# push workflow is shared and expected to perform actions after a merge happens +# on a maintenance branch (default or release). For example updating the +# draft release-notes. +# based on great work from +# https://github.com/T-Systems-MMS/ansible-collection-icinga-director +name: push_network + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +on: + push: + # branches to consider in the event; optional, defaults to all + branches: + - main + - 'releases/**' + - 'stable/**' + # Prevent a 2nd run after the changelog is updated + paths-ignore: + - CHANGELOG.rst + - changelogs/changelog.yaml + workflow_dispatch: + +env: + NAMESPACE: ansible + COLLECTION_NAME: utils + ANSIBLE_COLLECTIONS_PATHS: ./ + +jobs: + update_release_draft: + runs-on: ubuntu-22.04 + environment: push + steps: + - uses: actions/checkout@v3.5.0 + with: + repository: ${{ github.repository }} # ansible-collections/ansible.utils + fetch-depth: 0 + token: ${{ secrets.BOT_PAT }} + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: Install antsibull-changelog, antsichaut + run: > + python -m pip install + antsibull-changelog + git+https://github.com/ansible-community/antsichaut.git + pre-commit + --disable-pip-version-check + + - name: Run release drafter + id: release_drafter + uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Remove the v prefix from the release drafter version + run: | + VERSION=${{ steps.release_drafter.outputs.tag_name }} + echo "VERSION=${VERSION#v}" >> $GITHUB_ENV + + - name: Generate new version in changelog.yaml + run: antsibull-changelog release -v --version "${{ env.VERSION }}" + + - name: Get previous tag + id: previoustag + uses: "WyriHaximus/github-action-get-previous-tag@master" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + - name: Generate changelog.yaml + run: antsichaut + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SINCE_VERSION: "${{ steps.previoustag.outputs.tag }}" + + - name: Update Changelog.rst + run: antsibull-changelog generate -v + + - name: Cleanup to use prettier + run: pre-commit run prettier --all-files + continue-on-error: true + + - name: Update the glaxay.yml version + run: | + sed -i -e 's/version:.*/version: ${{ env.VERSION }}/' galaxy.yml + + - name: Determine if a PR is necessary + run: git diff --no-ext-diff --quiet --exit-code + continue-on-error: true + id: pr_check + + - name: Create PR for changelog + run: | + git config user.name "Ansible Bot" + git config user.email devtools@ansible.com + git checkout -t -b ${{ env.BRANCH_NAME }} + git add . + git commit -m "Changelog updated" + git push origin ${{ env.BRANCH_NAME }} + gh pr create --title "Changelog updated" --body "Changelog updated" --base main + if: steps.pr_check.outcome == 'failure' + env: + GH_TOKEN: ${{ secrets.BOT_PAT }} + BRANCH_NAME: chore-${{ github.workflow }}-${{ github.run_number }} From 7dad6ff394e82ae8ba11c635b89aea52c42ef72c Mon Sep 17 00:00:00 2001 From: KB-perByte Date: Fri, 26 May 2023 14:50:56 +0530 Subject: [PATCH 2/5] fix lint --- .github/workflows/push_network.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push_network.yml b/.github/workflows/push_network.yml index 50cb17c..5da354e 100644 --- a/.github/workflows/push_network.yml +++ b/.github/workflows/push_network.yml @@ -22,7 +22,7 @@ on: - changelogs/changelog.yaml workflow_dispatch: -env: +env: # needs to be generic or variable NAMESPACE: ansible COLLECTION_NAME: utils ANSIBLE_COLLECTIONS_PATHS: ./ @@ -34,7 +34,7 @@ jobs: steps: - uses: actions/checkout@v3.5.0 with: - repository: ${{ github.repository }} # ansible-collections/ansible.utils + repository: ${{ github.repository }} # ansible-collections/ansible.utils fetch-depth: 0 token: ${{ secrets.BOT_PAT }} From 80ad2339dd96eb1a6b69a9be7b9ec40207848158 Mon Sep 17 00:00:00 2001 From: KB-perByte Date: Fri, 26 May 2023 15:11:45 +0530 Subject: [PATCH 3/5] update workflow --- .github/workflows/push_network.yml | 33 +++++++++++------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/.github/workflows/push_network.yml b/.github/workflows/push_network.yml index 5da354e..78a9b16 100644 --- a/.github/workflows/push_network.yml +++ b/.github/workflows/push_network.yml @@ -5,27 +5,18 @@ # https://github.com/T-Systems-MMS/ansible-collection-icinga-director name: push_network -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - on: - push: - # branches to consider in the event; optional, defaults to all - branches: - - main - - 'releases/**' - - 'stable/**' - # Prevent a 2nd run after the changelog is updated - paths-ignore: - - CHANGELOG.rst - - changelogs/changelog.yaml - workflow_dispatch: - -env: # needs to be generic or variable - NAMESPACE: ansible - COLLECTION_NAME: utils - ANSIBLE_COLLECTIONS_PATHS: ./ + workflow_call: + # https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callinputs + inputs: + repo: + description: Publish to PyPI registry + required: true + type: string + secrets: + BOT_PAT: + description: Bot secret + required: true jobs: update_release_draft: @@ -34,7 +25,7 @@ jobs: steps: - uses: actions/checkout@v3.5.0 with: - repository: ${{ github.repository }} # ansible-collections/ansible.utils + repository: ${{ inputs.repo }} # ansible-collections/ansible.utils fetch-depth: 0 token: ${{ secrets.BOT_PAT }} From 5188c4446758bc382d88ea45d7aabd5f9e66e15e Mon Sep 17 00:00:00 2001 From: KB-perByte Date: Fri, 26 May 2023 15:13:21 +0530 Subject: [PATCH 4/5] update description --- .github/workflows/push_network.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_network.yml b/.github/workflows/push_network.yml index 78a9b16..ee141d0 100644 --- a/.github/workflows/push_network.yml +++ b/.github/workflows/push_network.yml @@ -10,7 +10,7 @@ on: # https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callinputs inputs: repo: - description: Publish to PyPI registry + description: Repository url required: true type: string secrets: From e2660c979dc8d5957a9a4a60d26034486fd71cd3 Mon Sep 17 00:00:00 2001 From: Sagar Paul Date: Mon, 29 May 2023 21:22:02 +0530 Subject: [PATCH 5/5] Update .github/workflows/push_network.yml Co-authored-by: Bikouo Aubin <79859644+abikouo@users.noreply.github.com> --- .github/workflows/push_network.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/push_network.yml b/.github/workflows/push_network.yml index ee141d0..70ebe25 100644 --- a/.github/workflows/push_network.yml +++ b/.github/workflows/push_network.yml @@ -77,7 +77,8 @@ jobs: - name: Update the glaxay.yml version run: | - sed -i -e 's/version:.*/version: ${{ env.VERSION }}/' galaxy.yml + pip install yq + yq -yi ".version = \"${{ env.VERSION }}\"" galaxy.yml - name: Determine if a PR is necessary run: git diff --no-ext-diff --quiet --exit-code