I am trying to build a workflow to build the package in my repository and push
it to the GitHub repository.
I used: os: [ubuntu-20.04, windows-2019, macos-11]
inside the job matrix and this is the final part of the workflow (the repo is checked out using actions/checkout@v3
):
- name: Upload
run: |
git config --global user.email "[email protected]"
git config --global user.name "user"
git add .
git commit -m "Build"
git push
Here is one problem that I think of:
Suppose the build on Ubuntu completes first. Then it gets to the Upload
step which uploads the built files to the repository.
Another machine completes its build (say, Windows). When it tries and run git push
, won’t it the repository not up to date error?
How can I fix this?
2
Answers
Add git remote origin before push command
git remote add origin https://github.com/{username}/{repository-name}.git
If I understand correctly, you have 3 jobs (one for each OS) building your project and pushing the build outputs back to the repo. The repo may not be the best place to store build outputs but if that is how you need it done I would do the following:
RUNNER_OS
environment variable.