- Notifications
You must be signed in to change notification settings - Fork261
Description
Description
Hi,
The issue is related to another popular GitHub Actionactions/checkout which allows to checkout the repository. Unfortunately, when checking out the repository that triggered a workflow, this defaults to the reference or SHA for that event. This means, that the subsequent jobs in the workflow will not include the updates made withPSR action.
For example if we have a workflow with 3 jobs, the first to run PSR and release package to GitHub, the second job to build and release image to Docker Hub(the image should include updated package with changelog changes, new version file, etc from the job 1), and the third job to build and release package to PyPI(the built package should also include all of the updates from the job 1).
Here is an example of this workflow(with some non-important steps amended):
jobs:release:name:Release Package to GitHuboutputs:released:${{ steps.release.outputs.released }}version:${{ steps.release.outputs.version }}tag:${{ steps.release.outputs.tag }}steps: -id:releasename:Python Semantic Releaseuses:python-semantic-release/python-semantic-release@masterdocker:name:Build and push Docker imageneeds:releasesteps: -name:Build and pushuses:docker/build-push-action@v5with:push:truetags:username/image:${{ needs.release.outputs.version }}, username/image:latestpypi:name:Publish to PyPIneeds:releasesteps: -name:Install dependencies -name:Download source codeuses:actions/checkout@v3 -name:Build package distributions -name:Publish package distributions to PyPI
The way GitHub actions works, the pypi and docker jobs will not include the commits made by release job. A simplegit pull to HEAD reference, will pull those commits; However, such solution can also introduce a race condition, in case there were other commits made while therelease job was running.More Info about this issue.
The correct solution would be for PSR GitHub Action to output the hash of the commit that has been made, which can be used in other jobs to pull the updates.
Use cases
Using separate jobs for updating version/releasing packages.
Possible implementation
Well, adding outputs would be easy(I assume), but I'm not sure how to get the commit hash after push, if someone can explain which function pushes the committed changes, I can try to work on the pull request.
Thank you