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

Publish artifacts in workflow #339

Merged
merged 4 commits into from
Apr 26, 2023
Merged

Publish artifacts in workflow #339

merged 4 commits into from
Apr 26, 2023

Conversation

korthout
Copy link
Owner

@korthout korthout commented Apr 26, 2023

This changes the CI workflow to package and publish the artifacts automatically.

By packaging and publishing the artifacts in a workflow, we avoid that they have to be part of a pull request. This allows us to eat our own dogfood and backport pull requests automatically. Previously, pull requests could not be backported because the commit with the artifacts would almost certainly lead to conflicts during cherry-picking.

This pull request also limits when the CI workflow is run. It used to be run both on any push, and on any pull_request event, which is excessive. The workflow actually only needs to be run on pull requests and on any push to main or release branch (release*). Additionally, contributors should not be able to change the CI that is run on their changes, so it should be run on pull_request_target instead of pull_request.

closes #312

We were unable to eat our own dogfood, because the artifacts always had
to be committed along with the source code changes in a pull request.
This would lead to conflicts when backporting the changes of the pull
request to an older release branch. By publishing the artifacts in a
separate step of the workflow, we can avoid that the commit with the
artifacts is part of the pull request.

The artifacts should only be published on pushes to the `main` branch
and on branches starting with `release` (which will be the naming scheme
for long living release branches in this repo).

Packaging the artifacts should always be done, to make sure a pull
request's changes don't break packaging the artifacts.
Packaging the artifacts goes really fast (few seconds), and failure may
indicate severe errors. It should be run before tests.
It should only be run on pushes to the main branch, on pushes to a
release branch, or in pull requests.

Contributors, should also not be able to change the CI workflow in their
pull request, so it should be run with pull_request_target instead of
pull_request.
GHA have a rule that workflows cannot be triggered on events caused by
the GITHUB_TOKEN. So, the commit pushed by the CI (publishing the
artifacts) would not trigger the release next preview workflow. But, it
should, because the next preview tag should point to the commit with the
artifacts.

To circumvent this, we can checkout the repo in the workflow with a PAT.
This PAT will automatically be used when committing and pushing the
packaged artifacts.

In addition to this commit, the repo now needs to specify a secret:
`BACKPORT_ACTION_PAT`. There are no workflows run on pull_request, so
this should be safe (secrets are not exposed to pull_request_target),
and contributors can't push directly to main or release branches.
@korthout korthout force-pushed the 312-build-artifacts-workflow branch from 42e211d to 8c5df58 Compare April 26, 2023 10:50
@korthout korthout merged commit 0ee4931 into main Apr 26, 2023
@korthout korthout deleted the 312-build-artifacts-workflow branch April 26, 2023 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to eat dogfood
1 participant