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 a safe-upload-artifacts action #601

Merged
merged 3 commits into from
Sep 18, 2024
Merged

Conversation

szczys
Copy link
Contributor

@szczys szczys commented Sep 18, 2024

This combined the functionality of the mask_secrets and upload-artifact actions.

This action takes a name and path input in the same formatting as the upload-artifact action, masks any GitHub actions found in the files on those paths, and then calls the upload-artifact action to upload them as expected.

resolves https://github.com/golioth/firmware-issue-tracker/issues/669

@szczys szczys changed the title safe upload artifacts Add a safe-upload-artifacts action Sep 18, 2024
@szczys szczys changed the base branch from main to szczys/add-twister-ci-summary September 18, 2024 00:38
@szczys szczys force-pushed the szczys/action-safe-upload-artifacts branch from db81573 to 4cea908 Compare September 18, 2024 00:40
Copy link

github-actions bot commented Sep 18, 2024

Visit the preview URL for this PR (updated for commit faa7ff1):

https://golioth-firmware-sdk-doxygen-dev--pr601-szczys-action-snj6ldvf.web.app

(expires Wed, 25 Sep 2024 19:11:15 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: a9993e61697a3983f3479e468bcb0b616f9a0578

@szczys szczys force-pushed the szczys/action-safe-upload-artifacts branch 2 times, most recently from f2770b5 to 919430f Compare September 18, 2024 01:13
Copy link

github-actions bot commented Sep 18, 2024

Code Coverage (Linux)

Type Coverage
lines 65.6% (1402 of 2138 lines)
functions 78.1% (139 of 178 functions)

@szczys szczys force-pushed the szczys/action-safe-upload-artifacts branch from 919430f to 4b4eb75 Compare September 18, 2024 01:26
Copy link

github-actions bot commented Sep 18, 2024

Code Coverage (Zephyr)

Code Coverage

Package Line Rate Branch Rate Health
include.golioth 75% 50%
port.zephyr 40% 19%
src 44% 23%
Summary 43% (1227 / 2823) 23% (468 / 2035)

@szczys szczys force-pushed the szczys/add-twister-ci-summary branch from c3adfc8 to 2db8622 Compare September 18, 2024 05:07
@szczys szczys force-pushed the szczys/action-safe-upload-artifacts branch from 4b4eb75 to 2ed0574 Compare September 18, 2024 05:08
@szczys szczys marked this pull request as ready for review September 18, 2024 05:18
@szczys szczys force-pushed the szczys/add-twister-ci-summary branch from 2db8622 to beabbda Compare September 18, 2024 14:10
Base automatically changed from szczys/add-twister-ci-summary to main September 18, 2024 15:53
@szczys szczys force-pushed the szczys/action-safe-upload-artifacts branch from 2ed0574 to 64667a9 Compare September 18, 2024 15:59
Copy link
Contributor

@sam-golioth sam-golioth left a comment

Choose a reason for hiding this comment

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

Very cool!

name: Mask secrets in files

description: |
Search all files in a give path(s) and replace any GitHub secrets with ***NAME_OF_SECRET***
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Search all files in a give path(s) and replace any GitHub secrets with ***NAME_OF_SECRET***
Search all files in a given path(s) and replace any GitHub secrets with ***NAME_OF_SECRET***

Comment on lines 58 to 60
uniq __grep_search_output.txt > __files_to_mask.txt

if [ -s __files_to_mask.txt ]; then
cat __files_to_mask.txt | xargs -I{} sed -i "s/$ESCAPED_SECRET/***$key***/g" {}
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove the need to write another file:

Suggested change
uniq __grep_search_output.txt > __files_to_mask.txt
if [ -s __files_to_mask.txt ]; then
cat __files_to_mask.txt | xargs -I{} sed -i "s/$ESCAPED_SECRET/***$key***/g" {}
fi
if [ -s __grep_search_output.txt ]; then
uniq __grep_search_output.txt | xargs -I{} sed -i "s/$ESCAPED_SECRET/***$key***/g" {}
fi


- name: Upload artifacts
uses: actions/upload-artifact@v4
if: steps.find-and-mask.outcome == 'success'
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is implied so we don't require it. We needed this before because we were using an if: always() directive, but now that's applied for the whole action instead of just the individual upload artifacts step.

@szczys szczys force-pushed the szczys/action-safe-upload-artifacts branch from 64667a9 to 0fdda77 Compare September 18, 2024 17:53
Add safe-upload-artifacts to combine the functionality of both the
mask_secrets and upload-artifact actions.

Signed-off-by: Mike Szczys <mike@golioth.io>
Use safe-upload-artifacts for twister run artifacts and summaries.

Signed-off-by: Mike Szczys <mike@golioth.io>
This has been replaced with safe-upload-artifacts.

Signed-off-by: Mike Szczys <mike@golioth.io>
@szczys szczys force-pushed the szczys/action-safe-upload-artifacts branch from 0fdda77 to faa7ff1 Compare September 18, 2024 19:10
@szczys szczys merged commit fac3d83 into main Sep 18, 2024
39 of 48 checks passed
@szczys szczys deleted the szczys/action-safe-upload-artifacts branch September 18, 2024 20:41
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.

2 participants