Skip to content

Commit

Permalink
ci: replace secrets automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
ptiurin committed Aug 19, 2024
1 parent d0681d7 commit ce9dea5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/replace.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/perl
# Replace a specific string in a file with a placeholder value
# work with any string, including special characters

use strict;
use warnings;

# Check if both arguments are provided
if (@ARGV != 2) {
die "Usage: perl replace_string.pl <string_to_replace> <file>\n";
}

my $string_to_replace = $ARGV[0];
my $file = $ARGV[1];

# Read the file content
open(my $fh, '<', $file) or die "Could not open file '$file' $!";
my $content = do { local $/; <$fh> };
close($fh);

# Replace the string
$content =~ s/\Q$string_to_replace\E/REDACTED/g;

# Write the updated content back to the file
open($fh, '>', $file) or die "Could not open file '$file' $!";
print $fh $content;
close($fh);
5 changes: 5 additions & 0 deletions .github/workflows/integration-tests-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ jobs:
run: |
pytest --last-failed -o log_cli=true -o log_cli_level=INFO tests/functional/ --alluredir=allure-results
- name: Make sure no secrets make it to the logs
run: |
find allure-results -type f -exec perl .github/replace.pl ${{ secrets.FIREBOLT_CLIENT_ID_STG_NEW_IDN }} {} +
find allure-results -type f -exec perl .github/replace.pl ${{ secrets.FIREBOLT_CLIENT_SECRET_STG_NEW_IDN }} {} +
- name: Save failed tests
id: cache-tests-save
uses: actions/cache/save@v3
Expand Down

0 comments on commit ce9dea5

Please sign in to comment.