Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(publish): Add allowlist for branches to take craft config from #3452

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,28 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node .__publish__/src/publish/post-workflow-details.js

# Setting the target repo branch will cause the craft config (.craft.yml) to be taken from the checked out branch
# By default, we check out the default branch of the repo.
# If you need to maintain diverging craft configs on different branches, add your repo and the merge target branch
# (i.e. the branch craft will merge the release branch into) into the if condition below.
- name: Set target repo checkout branch
# Note: Branches registered here MUST BE protected in the target repo!
if: |
fromJSON(steps.inputs.outputs.result).repo == 'sentry-javascript' && fromJSON(steps.inputs.outputs.result).merge_target == 'develop' ||
fromJSON(steps.inputs.outputs.result).repo == 'sentry-javascript' && fromJSON(steps.inputs.outputs.result).merge_target == 'v7' ||
fromJSON(steps.inputs.outputs.result).repo == 'sentry-migr8' && fromJSON(steps.inputs.outputs.result).merge_target == 'main' ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this first one wouldn't be needed since this is the default branch?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

fromJSON(steps.inputs.outputs.result).repo == 'sentry-migr8' && fromJSON(steps.inputs.outputs.result).merge_target == 'tmp-merge-target'
Copy link
Member Author

@Lms24 Lms24 Feb 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opted to temporarily add an entry for sentry-migr8 here so that I can test this before we add e.g. the JS SDK repo.

Copy link
Member Author

@Lms24 Lms24 Feb 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sentry-migr8 it should be fine to cut a few releases as it's still just a hackweek project at the moment
To test, I removed the npm target. We can even clean up the GH release afterwards.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add branch protection to that repo just so we're following the process

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id: target-repo-branch
run: |
target_repo_branch="{{ fromJSON(steps.inputs.outputs.result).merge_target }}"
echo 'taking craft config from branch {{ fromJSON(steps.inputs.outputs.result).merge_target }} in {{ fromJSON(steps.inputs.outputs.result).repo }}'

- uses: actions/checkout@v3
name: Check out target repo
if: ${{ steps.inputs.outputs.result }}
with:
path: __repo__
ref: ${{ steps.target-repo-branch.outputs.target_repo_branch || ''}}
repository: getsentry/${{ fromJSON(steps.inputs.outputs.result).repo }}
token: ${{ secrets.GH_SENTRY_BOT_PAT }}
fetch-depth: 0
Expand Down
Loading