diff --git a/.github/workflows/check-docs-current.yml b/.github/workflows/check-docs-current.yml index 78a2e50..1d15fe6 100644 --- a/.github/workflows/check-docs-current.yml +++ b/.github/workflows/check-docs-current.yml @@ -3,8 +3,63 @@ name: Check docs current on: workflow_call: +permissions: + contents: write + jobs: + scaffold-changes-template: + # Runs once, when the PR is first opened, to drop a copy-paste-ready + # .changes/*.yml template into the branch. Skipped for fork PRs. + if: >- + github.event.action == 'opened' && + github.event.pull_request.head.repo.full_name == github.repository + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GH_TOKEN }} + + - name: Checkout PR branch + run: | + git checkout -B "$BRANCH_NAME" "origin/$BRANCH_NAME" + git pull --rebase origin "$BRANCH_NAME" + env: + BRANCH_NAME: ${{ github.event.pull_request.head.ref }} + + - name: Skip if a changes entry or template already exists + id: existing + run: | + if ls .changes/*.yml >/dev/null 2>&1 || [ -f ".changes/TODO.yml.template" ]; then + echo "skip=true" >> "$GITHUB_OUTPUT" + else + echo "skip=false" >> "$GITHUB_OUTPUT" + fi + + - name: Download changes-template.yml + if: steps.existing.outputs.skip == 'false' + # Hardcoded to the changelog POC test branch for now (see GA-1035597). + # Update this ref once that work lands on main. + run: | + mkdir -p .changes + curl -sSfL \ + "https://raw.githubusercontent.com/fivetran/dbt_package_automations/refs/heads/changelog-poc/initial-test/templates/changes-template.yml" \ + -o .changes/TODO.yml.template + + - name: Commit and push the template + if: steps.existing.outputs.skip == 'false' + run: | + git config --global user.name "fivetran-data-model-bot" + git config --global user.email "fivetran-data-model-bot@users.noreply.github.com" + git add .changes/TODO.yml.template + git commit -m "Add .changes/*.yml template" || echo "No changes to commit" + git push origin "$BRANCH_NAME" + env: + BRANCH_NAME: ${{ github.event.pull_request.head.ref }} + check-docs: + if: github.event.action != 'opened' runs-on: ubuntu-latest steps: - name: Checkout @@ -42,7 +97,7 @@ jobs: RELEVANT_DOCS=$(relevant_since_last_touch 'docs/') RELEVANT_CHANGELOG=$(relevant_since_last_touch 'CHANGELOG.md') - RELEVANT_CHANGES_YML=$(relevant_since_last_touch '.changes/') + RELEVANT_CHANGES_YML=$(relevant_since_last_touch '.changes/*.yml') echo "BASE: $BASE" echo "HEAD: $HEAD" diff --git a/README.md b/README.md index 5f4caa2..b58e285 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This repository includes: - **GitHub Actions workflows** (`/.github/workflows/`) - `auto-release.yml` – Automates GitHub release creation - - `check-docs-current.yml` – Checks three things on every PR push: docs regenerated, `CHANGELOG.md` updated, and a `.changes/*.yml` entry present. Reports a single `docs/generated` commit status naming specifically which of the three are missing, and removes the `docs:ready` label if any are stale + - `check-docs-current.yml` – When a PR is opened, drops a `.changes/TODO.yml.template` into the branch if no `.changes/*.yml` entry exists yet (skipped for fork PRs). On every subsequent push, checks three things: docs regenerated, `CHANGELOG.md` updated, and a `.changes/*.yml` entry present. Reports a single `docs/generated` commit status naming specifically which of the three are missing, and removes the `docs:ready` label if any are stale - `generate-docs.yml` – When the `docs:ready` label is applied, generates dbt documentation **and** runs the changelog update (see below) in one job, committing both to the PR branch in a single push. Reports a `docs/generated` failure status and removes the `docs:ready` label if either step fails ## Changelog generation @@ -94,4 +94,6 @@ contributors: Only `version` is required — omit any section with nothing to report for this release. A blank, copy-paste-ready starting point lives at -[`templates/changes-template.yml`](templates/changes-template.yml). \ No newline at end of file +[`templates/changes-template.yml`](templates/changes-template.yml), and `check-docs-current.yml` +automatically drops a copy into new PRs as `.changes/TODO.yml.template` (the `.yml.template` +extension is deliberate — it's never picked up as a release until renamed to `.changes/{version}.yml`). \ No newline at end of file