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

Add build workflow (fix issue #35) #37

Merged
merged 2 commits into from
Sep 5, 2024
Merged

Add build workflow (fix issue #35) #37

merged 2 commits into from
Sep 5, 2024

Conversation

mkhansenbot
Copy link
Contributor

Checks to make sure no secrets are exposed, then searches for and runs any build script found

@mkhansenbot mkhansenbot force-pushed the add-build-workflow branch 6 times, most recently from 694c01f to 31555da Compare September 3, 2024 23:12
@mkhansenbot
Copy link
Contributor Author

@ivanperez-keera - please take a look. This and space-ros/space-ros#200 give the expected results. If you agree, I'll remove the temporary test commit from this (the "Delete this commit before merging") and merge this into the repo.

@ivanperez-keera
Copy link
Contributor

ivanperez-keera commented Sep 4, 2024

Seems good to me.

Just to make it clear, the check for the docker secrets does not in itself constitute any kind of protection: people could modify the .github/workflows/ directory and add another job. In this case, it's just that there are no secrets for this repo (apparently).

We still want to be careful with any PRs sent against the space-ros repo. We may want to disable automatically building PRs over there.

@mkhansenbot
Copy link
Contributor Author

I removed the test commit and updated the README with instructions, @ivanperez-keera and @EzraBrooks please approve and merge

Comment on lines 15 to 29
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Run the build.sh scripts
env:
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_RW_TOKEN }}
run: |
if [ -n "$DOCKER_HUB_TOKEN" ]
then
echo "Secrets detected, can't run build script"
exit 1 # terminate and indicate error
else
# find the build.sh scripts and execute them
find . -iname 'build.sh' -exec ./{} \;
fi
Copy link
Member

@EzraBrooks EzraBrooks Sep 4, 2024

Choose a reason for hiding this comment

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

I'm not sure the check is necessary; GitHub doesn't forward secrets into CI jobs dispatched from forks.

So, the only case in which the DOCKER_HUB_TOKEN would be populated is if one of us maintainers pushes a branch directly to this repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I just tested a PR from a fork into space-ros/space-ros and it looks like you're correct. I'll remove the secret check if we don't need it

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, the check itself won't matter, because the PR could alter the GA workflow.

What we wanted was to check that it was also not making the secret available to other repos.

Copy link
Member

Choose a reason for hiding this comment

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

What we wanted was to check that it was also not making the secret available to other repos.

which isn't possible anyway AFAIK. The only workflow type that is allowed to do this is pull_request_target, which we should be sure to never approve someone adding to the repo.

Copy link
Contributor

Choose a reason for hiding this comment

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

So, you can turn the step into:

    - name: Run the build.sh scripts
      run: |
              find . -iname 'build.sh' -exec ./{} \;
```

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I started to do that but then I realized that doesn't fail if the build.sh fails. find only fails if it fails to traverse a tree. I want to fail if any build.sh fails. Right now I've tried a few variations and can't seem to find one that works correctly, in both the passing and failing case

Copy link
Member

Choose a reason for hiding this comment

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

Probably need to change from find -exec to find | xargs

Copy link
Member

Choose a reason for hiding this comment

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

oh, interesting, GNU find (AKA what you have in Ubuntu) apparently has a -quit argument?

@mkhansenbot
Copy link
Contributor Author

Updated to call scripts directly, this works, please approve & merge

Copy link
Member

@EzraBrooks EzraBrooks left a comment

Choose a reason for hiding this comment

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

ah, wait, we need an issue reference in the commits here

@mkhansenbot mkhansenbot changed the title Add build workflow Add build workflow (fix issue #35) Sep 5, 2024
@mkhansenbot
Copy link
Contributor Author

Good catch, updated commit message and PR name to include issue #35

@mkhansenbot mkhansenbot merged commit c316131 into main Sep 5, 2024
1 check passed
@mkhansenbot mkhansenbot deleted the add-build-workflow branch September 5, 2024 14:32
@Bckempa Bckempa linked an issue Sep 5, 2024 that may be closed by this pull request
@Bckempa Bckempa added this to the jazzy-2024.10.0 milestone Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add build GH action to demos repo
4 participants