diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 30ac7f8..050a6ad 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -15,7 +15,7 @@ permissions: pull-requests: read jobs: - # Main filter detecting where in the repo changes have been made, allowing us to be smart about how we respond + detect-changes: runs-on: ubuntu-latest outputs: @@ -23,6 +23,7 @@ jobs: steps: - uses: actions/checkout@v4 + # Take different actions depending on what changed - uses: dorny/paths-filter@v3 id: check with: @@ -31,7 +32,33 @@ jobs: - 'tb_pulumi/**' - '.github/workflows/validate.yml' - # Run Ruff against tb_pulumi + detect-versions: + runs-on: ubuntu-latest + outputs: + branch-exists: ${{ steps.branch-exists.outputs.exists }} + version: v${{ steps.version.outputs.value }} + steps: + # Detect version from pyproject.toml + - uses: SebRollen/toml-action@v1.2.0 + id: version + with: + file: pyproject.toml + field: project.version + - uses: GuillaumeFalourd/branch-exists@v1 + id: branch-exists + with: + branch: v${{ steps.version.outputs.value }} + + # Fail on version collision + version-collision: + needs: detect-versions + runs-on: ubuntu-latest + if: needs.detect-versions.outputs.branch-exists == 'true' + steps: + - name: "Error: version collision" + run: exit 1 + + # Run Ruff, our linter, against tb_pulumi lint: needs: detect-changes runs-on: ubuntu-latest @@ -44,3 +71,17 @@ jobs: with: src: './tb_pulumi' args: 'format --check' + + # Cut a new branch if there isn't one with this version number + # cut-version-branch: + # needs: detect-versions + # runs-on: ubuntu-latest + # permissions: + # contents: write + # if: needs.detect-versions.outputs.branch-exists == 'false' + # steps: + # - name: Create a new version branch + # uses: peterjgrainger/action-create-branch@v2.2.0 + # with: + # branch: ${{ needs.detect-versions.outputs.version }} + # sha: ${{ github.event.pull_request.head.sha }}