diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7a6cc28..902ee31 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,14 +1,16 @@ name: Build and Test on: + pull_request: + paths-ignore: + - "**.md" push: branches: + - master - release/** - pull_request: - types: - - opened - - synchronize - - reopened + paths-ignore: + - "**.md" + env: # Variables defined in the repository @@ -38,16 +40,34 @@ jobs: with: fetch-depth: 0 - - name: Extract docker tag from action.yml + - name: Set git user to getsentry-bot + if: github.ref == 'refs/heads/master' run: | - TAG=$(yq '... | select(has("uses") and .uses | test("docker://ghcr.io/getsentry/action-release-image:.*")) | .uses' action.yml | awk -F':' '{print $3}') - echo "DOCKER_TAG=$TAG" >> $GITHUB_ENV - - if [[ "${{ github.event_name }}" == "pull_request" ]]; then - if [[ "$TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "Error: DOCKER_TAG $TAG matching format MAJOR.MINOR.PATCH is not allowed inside pull requests." - echo "Please rename the docker tag in action.yml and try again." - exit 1 + echo "GIT_COMMITTER_NAME=getsentry-bot" >> $GITHUB_ENV; + echo "GIT_AUTHOR_NAME=getsentry-bot" >> $GITHUB_ENV; + echo "EMAIL=bot@sentry.io" >> $GITHUB_ENV; + + - name: Evaluate docker tag + run: | + if [[ "${{ github.ref }}" == "refs/heads/master" ]]; then + echo "DOCKER_TAG=master" >> $GITHUB_ENV + yarn set-docker-tag master + + if ! git diff --quiet action.yml; then + git add action.yml + git commit -m "chore: Set docker tag for master [skip-ci]" + git push + fi + else + TAG=$(yq '... | select(has("uses") and .uses | test("docker://ghcr.io/getsentry/action-release-image:.*")) | .uses' action.yml | awk -F':' '{print $3}') + echo "DOCKER_TAG=$TAG" >> $GITHUB_ENV + + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + if [[ "$TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Error: DOCKER_TAG $TAG matching format MAJOR.MINOR.PATCH is not allowed inside pull requests." + echo "Please rename the docker tag in action.yml and try again." + exit 1 + fi fi fi diff --git a/.github/workflows/verify-dist.yml b/.github/workflows/verify-dist.yml index e05c1ba..0d87b5d 100644 --- a/.github/workflows/verify-dist.yml +++ b/.github/workflows/verify-dist.yml @@ -8,6 +8,7 @@ on: push: branches: - master + - release/** paths-ignore: - "**.md" pull_request: diff --git a/docs/development.md b/docs/development.md index 5a981a0..0a108c9 100644 --- a/docs/development.md +++ b/docs/development.md @@ -41,8 +41,8 @@ Members of this repo will not have to set anything up since [the integration](ht > [!WARNING] > After you create a branch ALWAYS run yarn set-docker-tag-from-branch. -> This is very important. You should avoid publishing changes to an already existing docker image. -> +> This is very important. You should avoid publishing changes to an already existing docker image. +> > Tags matching MAJOR.MINOR.PATCH (e.g. `1.10.2`) will be automatically rejected. 1. Create a branch