ci: skip auto-generated changelog and contributors commits in release… #288
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Continuous Integration | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - '.github/workflows/**' | |
| - '**/*.md' | |
| - 'test/**' | |
| - 'backup/**' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| unit-tests: | |
| name: Unit Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: '1.26' | |
| - name: Run Go unit tests with coverage | |
| run: go test ./internal/... -v -cover -coverprofile=coverage.out | |
| - name: Display coverage summary | |
| run: go tool cover -func=coverage.out | |
| build-and-push-docker: | |
| name: Build and Push Docker | |
| needs: unit-tests | |
| runs-on: ubuntu-latest | |
| services: | |
| registry: | |
| image: registry:2 | |
| ports: | |
| - 5001:5000 | |
| env: | |
| TEST_TAG: localhost:5001/actions/go-git-commit-action:latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 10 | |
| token: ${{ secrets.PAT_TOKEN }} | |
| - name: Configure Git Safe Directory | |
| run: git config --global --add safe.directory ${{ github.workspace }} | |
| - name: Setup Docker BuildX | |
| uses: docker/setup-buildx-action@v4 | |
| with: | |
| install: true | |
| driver-opts: network=host | |
| - name: Build the Container | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ env.TEST_TAG }} | |
| - name: Create Test File | |
| run: | | |
| echo "$(date +%s)-$RANDOM" > test/test1.txt | |
| - name: Run the Container | |
| env: | |
| USER_EMAIL: actions@github.com | |
| USER_NAME: GitHub Actions | |
| COMMIT_MESSAGE: test1 ${{ github.run_id }}! | |
| BRANCH: test | |
| REPOSITORY_PATH: test | |
| FILE_PATTERN: . | |
| TAG_NAME: test1-${{ github.run_id }} | |
| TAG_MESSAGE: test1 ${{ github.run_id }} | |
| TAG_REFERENCE: v1.0.1 | |
| run: | | |
| docker run \ | |
| --env INPUT_USER_EMAIL="${{ env.USER_EMAIL }}" \ | |
| --env INPUT_USER_NAME="${{ env.USER_NAME }}" \ | |
| --env INPUT_COMMIT_MESSAGE="${{ env.COMMIT_MESSAGE }}" \ | |
| --env INPUT_BRANCH="${{ env.BRANCH }}" \ | |
| --env INPUT_REPOSITORY_PATH="${{ env.REPOSITORY_PATH }}" \ | |
| --env INPUT_FILE_PATTERN="${{ env.FILE_PATTERN }}" \ | |
| --env INPUT_TAG_NAME="${{ env.TAG_NAME }}" \ | |
| --env INPUT_TAG_MESSAGE="${{ env.TAG_MESSAGE }}" \ | |
| --env INPUT_TAG_REFERENCE="${{ env.TAG_REFERENCE }}" \ | |
| --env GITHUB_TOKEN="${{ secrets.PAT_TOKEN }}" \ | |
| --volume ${{ github.workspace }}:/app \ | |
| --rm ${{ env.TEST_TAG }} | |
| - name: Confirm Tag Reference | |
| run: | | |
| git show -1 v1.0.1 | |
| git show -1 test1-${{ github.run_id }} | |
| - name: Delete Tag | |
| env: | |
| USER_EMAIL: actions@github.com | |
| USER_NAME: GitHub Actions | |
| BRANCH: main | |
| TAG_NAME: test1-${{ github.run_id }} | |
| TAG_MESSAGE: test1 ${{ github.run_id }} | |
| run: | | |
| docker run \ | |
| --env INPUT_USER_EMAIL="${{ env.USER_EMAIL }}" \ | |
| --env INPUT_USER_NAME="${{ env.USER_NAME }}" \ | |
| --env INPUT_BRANCH="${{ env.BRANCH }}" \ | |
| --env INPUT_TAG_NAME="${{ env.TAG_NAME }}" \ | |
| --env INPUT_DELETE_TAG="true" \ | |
| --env GITHUB_TOKEN="${{ secrets.PAT_TOKEN }}" \ | |
| --volume ${{ github.workspace }}:/app \ | |
| --rm ${{ env.TEST_TAG }} | |
| test-action-auto-branch-false: | |
| name: Test Auto Branch False | |
| runs-on: ubuntu-latest | |
| needs: build-and-push-docker | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 10 | |
| - name: Test Auto Branch Local Action (auto_branch false) | |
| uses: ./ | |
| with: | |
| user_email: actions@github.com | |
| user_name: GitHub Actions | |
| branch: test | |
| create_pr: true | |
| auto_branch: false | |
| pr_title: test-pr-title | |
| pr_base: main | |
| pr_branch: test | |
| pr_labels: "test,automated,auto-branch-false-test" | |
| repository_path: test | |
| file_pattern: . | |
| github_token: ${{ secrets.PAT_TOKEN }} | |
| pr_closed: true | |
| test-action-auto-branch-true: | |
| name: Test Auto Branch True | |
| runs-on: ubuntu-latest | |
| needs: [build-and-push-docker, test-action-auto-branch-false] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 10 | |
| token: ${{ secrets.PAT_TOKEN }} | |
| - name: Create Test File | |
| run: | | |
| echo "$(date +%s)-$RANDOM" > test/test2.txt | |
| - name: Test Auto Branch Local Action (auto_branch true) | |
| uses: ./ | |
| with: | |
| user_email: actions@github.com | |
| user_name: GitHub Actions | |
| branch: test | |
| create_pr: true | |
| auto_branch: true | |
| pr_base: main | |
| pr_labels: "test,automated,auto-branch-true-test" | |
| repository_path: test | |
| file_pattern: . | |
| delete_source_branch: true | |
| github_token: ${{ secrets.PAT_TOKEN }} | |
| pr_closed: true | |
| test-skip-if-empty: | |
| name: Test Skip If Empty | |
| runs-on: ubuntu-latest | |
| needs: [test-action-auto-branch-true] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 10 | |
| token: ${{ secrets.PAT_TOKEN }} | |
| - name: Test Skip If Empty (should skip - no changes) | |
| id: skip-test | |
| uses: ./ | |
| with: | |
| user_email: actions@github.com | |
| user_name: GitHub Actions | |
| branch: test | |
| create_pr: true | |
| auto_branch: false | |
| pr_base: main | |
| pr_branch: test | |
| repository_path: test | |
| file_pattern: . | |
| skip_if_empty: true | |
| pr_title: "Test Skip If Empty - No Changes (should skip)" | |
| pr_labels: "test,automated,skip-if-empty-test" | |
| github_token: ${{ secrets.PAT_TOKEN }} | |
| pr_closed: true | |
| - name: Verify Skip Output | |
| run: | | |
| echo "skipped=${{ steps.skip-test.outputs.skipped }}" | |
| echo "changed_files=${{ steps.skip-test.outputs.changed_files }}" | |
| if [ "${{ steps.skip-test.outputs.skipped }}" != "true" ]; then | |
| echo "FAIL: expected skipped=true" | |
| exit 1 | |
| fi | |
| echo "PASS: skip output verified" | |
| # Verify skip does not happen when changes exist | |
| - name: Create Test File | |
| run: | | |
| echo "$(date +%s)-$RANDOM" > test/skip-test.txt | |
| - name: Test Skip If Empty (should not skip - with changes) | |
| id: no-skip-test | |
| uses: ./ | |
| with: | |
| user_email: actions@github.com | |
| user_name: GitHub Actions | |
| branch: test | |
| create_pr: true | |
| auto_branch: true | |
| pr_base: main | |
| pr_labels: "test,automated,skip-if-empty-test" | |
| repository_path: test | |
| delete_source_branch: true | |
| file_pattern: . | |
| skip_if_empty: true | |
| pr_title: "Test Skip If Empty - With Changes (should not skip)" | |
| github_token: ${{ secrets.PAT_TOKEN }} | |
| pr_closed: true | |
| - name: Verify No-Skip Output | |
| run: | | |
| echo "skipped=${{ steps.no-skip-test.outputs.skipped }}" | |
| echo "changed_files=${{ steps.no-skip-test.outputs.changed_files }}" | |
| echo "pr_number=${{ steps.no-skip-test.outputs.pr_number }}" | |
| echo "pr_url=${{ steps.no-skip-test.outputs.pr_url }}" | |
| if [ "${{ steps.no-skip-test.outputs.skipped }}" = "true" ]; then | |
| echo "FAIL: expected skipped!=true" | |
| exit 1 | |
| fi | |
| echo "PASS: no-skip output verified" | |
| test-pr-auto-close-pr-body: | |
| name: Test PR Auto Close | |
| runs-on: ubuntu-latest | |
| needs: [test-skip-if-empty] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 10 | |
| token: ${{ secrets.PAT_TOKEN }} | |
| - name: Configure Git Safe Directory | |
| run: git config --global --add safe.directory ${{ github.workspace }} | |
| - name: Test PR Auto Close | |
| uses: ./ | |
| with: | |
| user_email: actions@github.com | |
| user_name: GitHub Actions | |
| branch: test | |
| pr_branch: test | |
| create_pr: true | |
| pr_base: main | |
| repository_path: test | |
| file_pattern: . | |
| pr_closed: true | |
| pr_labels: "test,automated,auto-close-pr-body-test" | |
| pr_title: "Test Auto Close PR" | |
| pr_body: | | |
| ## Test Auto Close PR | |
| This PR will be automatically closed after creation. | |
| github_token: ${{ secrets.PAT_TOKEN }} | |
| test-pr-dry-run: | |
| name: Test PR Dry Run | |
| runs-on: ubuntu-latest | |
| needs: [test-pr-auto-close-pr-body] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 10 | |
| token: ${{ secrets.PAT_TOKEN }} | |
| - name: Test PR Dry Run (auto_branch false) | |
| uses: ./ | |
| with: | |
| user_email: actions@github.com | |
| user_name: GitHub Actions | |
| branch: main | |
| create_pr: true | |
| auto_branch: false | |
| pr_title: "Test PR Dry Run" | |
| pr_base: test | |
| pr_branch: main | |
| pr_labels: "test,automated,dry-run-test" | |
| repository_path: "test" | |
| file_pattern: "pr-dry-run-test.txt" | |
| github_token: ${{ secrets.PAT_TOKEN }} | |
| pr_dry_run: true | |
| - name: Test PR Dry Run with Draft | |
| uses: ./ | |
| with: | |
| user_email: actions@github.com | |
| user_name: GitHub Actions | |
| branch: main | |
| create_pr: true | |
| auto_branch: false | |
| pr_title: "Test PR Dry Run (Draft)" | |
| pr_base: test | |
| pr_branch: main | |
| pr_labels: "test,automated,draft-pr-test" | |
| repository_path: "test" | |
| file_pattern: "pr-dry-run-test.txt" | |
| github_token: ${{ secrets.PAT_TOKEN }} | |
| pr_draft: true | |
| pr_dry_run: true | |
| - name: Test PR Dry Run with Reviewers and Assignees | |
| uses: ./ | |
| with: | |
| user_email: actions@github.com | |
| user_name: GitHub Actions | |
| branch: main | |
| create_pr: true | |
| auto_branch: false | |
| pr_title: "Test PR Dry Run (Reviewers/Assignees)" | |
| pr_base: test | |
| pr_branch: main | |
| pr_labels: "test,automated,reviewers-test" | |
| pr_reviewers: "somaz94" | |
| pr_assignees: "somaz94" | |
| repository_path: "test" | |
| file_pattern: "pr-dry-run-test.txt" | |
| github_token: ${{ secrets.PAT_TOKEN }} | |
| pr_dry_run: true | |
| ci-result: | |
| name: CI Result | |
| if: always() | |
| needs: | |
| - unit-tests | |
| - build-and-push-docker | |
| - test-action-auto-branch-false | |
| - test-action-auto-branch-true | |
| - test-skip-if-empty | |
| - test-pr-auto-close-pr-body | |
| - test-pr-dry-run | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check all jobs | |
| run: | | |
| if [ "${{ contains(needs.*.result, 'failure') }}" = "true" ] || \ | |
| [ "${{ contains(needs.*.result, 'cancelled') }}" = "true" ]; then | |
| echo "[FAIL]Some jobs failed or were cancelled" | |
| exit 1 | |
| fi | |
| echo "[PASS]All CI jobs passed" |