Skip to content

Commit f42dbcf

Browse files
committed
Add logic to commit master docker tag on master runs
1 parent 608b1f0 commit f42dbcf

File tree

3 files changed

+37
-16
lines changed

3 files changed

+37
-16
lines changed

.github/workflows/build.yml

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
name: Build and Test
22

33
on:
4+
pull_request:
5+
paths-ignore:
6+
- "**.md"
47
push:
58
branches:
9+
- master
610
- release/**
7-
pull_request:
8-
types:
9-
- opened
10-
- synchronize
11-
- reopened
11+
paths-ignore:
12+
- "**.md"
13+
1214

1315
env:
1416
# Variables defined in the repository
@@ -38,16 +40,34 @@ jobs:
3840
with:
3941
fetch-depth: 0
4042

41-
- name: Extract docker tag from action.yml
43+
- name: Set git user to getsentry-bot
44+
if: github.ref == 'refs/heads/master'
4245
run: |
43-
TAG=$(yq '... | select(has("uses") and .uses | test("docker://ghcr.io/getsentry/action-release-image:.*")) | .uses' action.yml | awk -F':' '{print $3}')
44-
echo "DOCKER_TAG=$TAG" >> $GITHUB_ENV
45-
46-
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
47-
if [[ "$TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
48-
echo "Error: DOCKER_TAG $TAG matching format MAJOR.MINOR.PATCH is not allowed inside pull requests."
49-
echo "Please rename the docker tag in action.yml and try again."
50-
exit 1
46+
echo "GIT_COMMITTER_NAME=getsentry-bot" >> $GITHUB_ENV;
47+
echo "GIT_AUTHOR_NAME=getsentry-bot" >> $GITHUB_ENV;
48+
echo "[email protected]" >> $GITHUB_ENV;
49+
50+
- name: Evaluate docker tag
51+
run: |
52+
if [[ "${{ github.ref }}" == "refs/heads/master" ]]; then
53+
echo "DOCKER_TAG=master" >> $GITHUB_ENV
54+
yarn run set-docker-tag master
55+
56+
if ! git diff --quiet action.yml; then
57+
git add action.yml
58+
git commit -m "chore: Set docker tag for master [skip-ci]"
59+
git push
60+
fi
61+
else
62+
TAG=$(yq '... | select(has("uses") and .uses | test("docker://ghcr.io/getsentry/action-release-image:.*")) | .uses' action.yml | awk -F':' '{print $3}')
63+
echo "DOCKER_TAG=$TAG" >> $GITHUB_ENV
64+
65+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
66+
if [[ "$TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
67+
echo "Error: DOCKER_TAG $TAG matching format MAJOR.MINOR.PATCH is not allowed inside pull requests."
68+
echo "Please rename the docker tag in action.yml and try again."
69+
exit 1
70+
fi
5171
fi
5272
fi
5373

.github/workflows/verify-dist.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
push:
99
branches:
1010
- master
11+
- release/**
1112
paths-ignore:
1213
- "**.md"
1314
pull_request:

docs/development.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ Members of this repo will not have to set anything up since [the integration](ht
4141

4242
> [!WARNING]
4343
> After you create a branch ALWAYS run yarn set-docker-tag-from-branch.
44-
> This is very important. You should avoid publishing changes to an already existing docker image.
45-
>
44+
> This is very important. You should avoid publishing changes to an already existing docker image.
45+
>
4646
> Tags matching MAJOR.MINOR.PATCH (e.g. `1.10.2`) will be automatically rejected.
4747
4848
1. Create a branch

0 commit comments

Comments
 (0)