diff --git a/.github/actions/git/configure-identity/action.yml b/.github/actions/git/configure-identity/action.yml new file mode 100644 index 00000000..ece38a74 --- /dev/null +++ b/.github/actions/git/configure-identity/action.yml @@ -0,0 +1,12 @@ +name: 'Configure git identity' +author: 'Pete Sramek' +description: 'Configures git user name and email from the last commit.' + +runs: + using: composite + steps: + - name: 'Configure git identity' + shell: bash + run: | + git config user.name "$(git log -n 1 --pretty=format:%an)" + git config user.email "$(git log -n 1 --pretty=format:%ae)" diff --git a/.github/actions/git/push-changes/action.yml b/.github/actions/git/push-changes/action.yml index 31ddd3f2..5c728462 100644 --- a/.github/actions/git/push-changes/action.yml +++ b/.github/actions/git/push-changes/action.yml @@ -87,12 +87,14 @@ runs: set -e working-directory: ${{ inputs.working-directory }} + - name: Configure git identity + if: ${{ fromJSON(steps.validate.outputs.has-changes) == '1' }} + uses: './.github/actions/git/configure-identity' + - name: Push changes to ${{ github.head_ref || github.ref }} if: ${{ fromJSON(steps.validate.outputs.has-changes) == '1' }} shell: bash run: | - git config user.name "$(git log -n 1 --pretty=format:%an)" - git config user.email "$(git log -n 1 --pretty=format:%ae)" git commit -m '${{ inputs.commit-message }}' git pull --rebase origin ${{ github.head_ref || github.ref }} git push diff --git a/.github/actions/github/create-release/action.yml b/.github/actions/github/create-release/action.yml index 0e0015ce..c8425d12 100644 --- a/.github/actions/github/create-release/action.yml +++ b/.github/actions/github/create-release/action.yml @@ -23,18 +23,21 @@ runs: echo "is-preview=${{ inputs.is-preview }}" echo "preview-argument=${{ inputs.is-preview == 'true' && '--prerelease' || '' }}" echo "notes-start-tag=${{ inputs.notes-start-tag }}" - echo "notes-start-tag-argument="${{ inputs.notes-start-tag != '' && '--notes-start-tag $(inputs.notes-start-tag)' || '' }}" + echo "notes-start-tag-argument=${{ inputs.notes-start-tag != '' && format('--notes-start-tag {0}', inputs.notes-start-tag) || '' }}" shell: bash - - name: 'Create git tag ${{ env.release-version }}' + - name: 'Configure git identity' + uses: './.github/actions/git/configure-identity' + - name: 'Create git tag ${{ inputs.release-version }}' shell: bash run: | - git tag -a ${{ env.release-version }} -m "${{ env.release-version }}" - - name: 'Create GitHub release PolylineAlgorithm ${{ env.release-version }}' + git tag -a ${{ inputs.release-version }} -m "${{ inputs.release-version }}" + git push origin ${{ inputs.release-version }} + - name: 'Create GitHub release PolylineAlgorithm ${{ inputs.release-version }}' shell: bash env: GH_TOKEN: ${{ github.token }} release-version: ${{ inputs.release-version }} preview-argument: "${{ inputs.is-preview == 'true' && '--prerelease' || '' }}" - notes-start-tag-argument: "${{ inputs.notes-start-tag != '' && '--notes-start-tag $(inputs.notes-start-tag)' || '' }}" + notes-start-tag-argument: "${{ inputs.notes-start-tag != '' && format('--notes-start-tag {0}', inputs.notes-start-tag) || '' }}" run: | gh release create ${{ env.release-version }} --generate-notes --discussion-category "General" ${{ env.preview-argument }} ${{ env.notes-start-tag-argument }} diff --git a/.github/workflows/backtrack.yml b/.github/workflows/backtrack.yml index 82f5483b..9149061f 100644 --- a/.github/workflows/backtrack.yml +++ b/.github/workflows/backtrack.yml @@ -30,9 +30,7 @@ jobs: token: ${{ secrets.GH_ADMIN_TOKEN }} - name: 'Configure git' - run: | - git config user.name "$(git log -n 1 --pretty=format:%an)" - git config user.email "$(git log -n 1 --pretty=format:%ae)" + uses: './.github/actions/git/configure-identity' - name: 'Resolve backtrack targets' id: targets diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index 6f79680c..2abd97ba 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -113,9 +113,7 @@ jobs: dotnet-version: ${{ env.dotnet-sdk-version }} - name: 'Configure git' - run: | - git config user.name "$(git log -n 1 --pretty=format:%an)" - git config user.email "$(git log -n 1 --pretty=format:%ae)" + uses: './.github/actions/git/configure-identity' - name: 'Create develop branch from main' run: | diff --git a/.github/workflows/promote-branch.yml b/.github/workflows/promote-branch.yml index 8e566ec3..31300ba8 100644 --- a/.github/workflows/promote-branch.yml +++ b/.github/workflows/promote-branch.yml @@ -60,6 +60,8 @@ jobs: target-branch-exists: ${{ steps.check-target-branch-exists.outputs.target-branch-exists }} pull-request-exists: ${{ steps.check-pull-request-exists.outputs.pull-request-exists }} steps: + - name: 'Checkout ${{ github.head_ref || github.ref }}' + uses: actions/checkout@v6 - name: 'Set target branch' id: set-target-branch run: | @@ -211,12 +213,6 @@ jobs: run: | git fetch origin git push origin origin/${{ env.base-branch }}:refs/heads/${{ env.target-branch }} - - name: 'Lock target branch' - if: ${{ needs.workflow-variables.outputs.target-branch-exists == 'false' }} - uses: './.github/actions/github/branch-protection/lock' - with: - branch: ${{ needs.workflow-variables.outputs.target-branch }} - token: ${{ secrets.GH_ADMIN_TOKEN }} - name: 'Create PR: "Promote ${{ env.current-branch }} to ${{ env.target-branch }}"' if: ${{ needs.workflow-variables.outputs.pull-request-exists == 'false' }} env: @@ -224,4 +220,5 @@ jobs: current-branch: ${{ github.ref_name }} target-branch: ${{ needs.workflow-variables.outputs.target-branch }} run: | + git fetch origin ${{ env.target-branch }} gh pr create --title "Promote ${{ env.current-branch }} to ${{ env.target-branch }}" --fill --base ${{ env.target-branch }} --head ${{ env.current-branch }} diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 29392ddf..4f8917b0 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -8,8 +8,9 @@ on: - synchronize - reopened branches: + - 'develop/**' - 'preview/**' - - 'release/**' + - 'release/**' permissions: actions: read diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f8997287..0d2808a8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -277,6 +277,9 @@ jobs: needs: [workflow-variables, release, versioning] if: ${{ needs.workflow-variables.outputs.is-release == 'true' }} runs-on: ubuntu-latest + permissions: + pull-requests: write + contents: read env: GH_TOKEN: ${{ github.token }} current-branch: ${{ github.ref_name }} @@ -358,11 +361,13 @@ jobs: echo "support-branch-exists=false" >> $GITHUB_OUTPUT fi + - name: 'Configure git identity' + if: ${{ steps.check-support-branch.outputs.support-branch-exists == 'false' }} + uses: './.github/actions/git/configure-identity' + - name: 'Create support branch' if: ${{ steps.check-support-branch.outputs.support-branch-exists == 'false' }} run: | - git config user.name "$(git log -n 1 --pretty=format:%an)" - git config user.email "$(git log -n 1 --pretty=format:%ae)" git checkout -b "${{ steps.resolve-support-branch.outputs.support-branch }}" git push --set-upstream origin "${{ steps.resolve-support-branch.outputs.support-branch }}"