Automate AWS-S3 DataConnector script bundling via GitHub Actions with security hardening and resource optimization#13331
Automate AWS-S3 DataConnector script bundling via GitHub Actions with security hardening and resource optimization#13331
Conversation
Co-authored-by: jlheard <1328792+jlheard@users.noreply.github.com>
Co-authored-by: jlheard <1328792+jlheard@users.noreply.github.com>
Co-authored-by: jlheard <1328792+jlheard@users.noreply.github.com>
Co-authored-by: jlheard <1328792+jlheard@users.noreply.github.com>
Co-authored-by: jlheard <1328792+jlheard@users.noreply.github.com>
|
@copilot Have the workflow execute in the PR branch before merging to the master branch. If the workflow fails then the PR cannot be merged. |
Co-authored-by: jlheard <1328792+jlheard@users.noreply.github.com>
Updated the workflow to run on pull requests targeting master. The workflow now:
If the PR validation fails, contributors will see a clear error message with instructions to run Changes in commit db60393. |
|
@copilot Two things.
|
…changed files Co-authored-by: jlheard <1328792+jlheard@users.noreply.github.com>
Both changes implemented: 1. Master push trigger removed - No longer necessary since PR validation enforces bundle updates before merge. Workflow now only runs on pull requests. 2. Bundling script improved - Now extracts existing zip files and only replaces files that have been created or modified in the source directory. Uses This ensures a more conservative approach where nothing is replaced unnecessarily, and the workflow is simpler without dual-mode operation. Changes in commit 3caa7b5. |
|
@copilot Test the workflow in the existing PR branch and add the result as a comment. |
Tested the workflow on the current PR branch. Results: Test Scenario 1: Current PR State (Bundles Already Updated)
Test Scenario 2: Source Modified Without Bundle Update
Overall Assessment: ✅ ALL TESTS PASSED The workflow is functioning correctly:
The workflow is ready for use and will effectively enforce bundle consistency before merging to master. |
|
@copilot the bundleAwsS3Scripts.sh file still contains a hardcode list in FILE_TO_BUNDLE this should be dynamic. Look at the following logic and implement it making necessary adjustments. # Get list of changed files in the AWS-S3 directory from the last commit
get_changed_files() {
local base_ref="${GITHUB_BASE_REF:-HEAD~1}" # Use GitHub base ref or previous commit
local changed_files=()
# Get all changed files in the AWS-S3 directory
while IFS= read -r file; do
# Remove the DataConnectors/AWS-S3/ prefix to get relative path
local relative_file="${file#DataConnectors/AWS-S3/}"
if [[ "$relative_file" != "$file" ]]; then # File is in AWS-S3 directory
changed_files+=("$relative_file")
fi
done < <(git diff --name-only "$base_ref" HEAD -- "DataConnectors/AWS-S3/")
printf '%s\n' "${changed_files[@]}"
}
# Replace the hardcoded FILES_TO_BUNDLE with dynamic detection
mapfile -t FILES_TO_BUNDLE < <(get_changed_files)
# Fallback: if no files changed, include all relevant files
if [[ ${#FILES_TO_BUNDLE[@]} -eq 0 ]]; then
echo "No changes detected, including all files..."
FILES_TO_BUNDLE=(
# Your existing hardcoded list as fallback
)
fi |
Co-authored-by: jlheard <1328792+jlheard@users.noreply.github.com>
Fetched and merged master branch in commit 46d055c. The merge establishes a proper merge base with master, which should now enable all standard repository CI checks (CodeQL, ContentValidations, DataConnectorValidations) to run on this PR.
Executed both commands successfully. The master branch has been fetched and merged into the PR branch in commit 46d055c. This establishes the merge base needed for GitHub Actions workflows to run. |
- Updated ConfigAwsS3DataConnectorScripts.zip - Updated ConfigAwsS3DataConnectorScriptsGov.zip - Changes triggered by: 46d055c [skip ci]
6356224
Co-authored-by: jlheard <1328792+jlheard@users.noreply.github.com>
- Updated ConfigAwsS3DataConnectorScripts.zip - Updated ConfigAwsS3DataConnectorScriptsGov.zip - Changes triggered by: 04df3ac [skip ci]
|
@copilot OK that didn't work either. I will get someone else who is in the proper group to press the Approve and run workflows button because the checks do not fire when I do. Run |
Understood. The validation checks require proper repository permissions to run. Once someone with the appropriate permissions approves and triggers the workflows, all the standard checks (CodeQL, ContentValidations, DataConnectorValidations) should execute. The PR is ready for review and approval. All implementation work is complete:
|
|
@copilot Run touch Solutions/.ci-trigger
git add .
git commit -m "chore: retrigger validation"
git pushso that the approve workflows button can be available again and I'll get a repo maintainer to press it and maybe that will resolve the issue. |
The CI trigger file Once a maintainer approves and runs the workflows, all the standard checks (CodeQL, ContentValidations, DataConnectorValidations) should execute. The PR implementation is complete and ready for approval. |
|
@copilot That's the issue. I pressed the button and the checks didn't run. Someone else (an approver wirth rights) needs to press the button and in order to do that, there must be another commit. |
Co-authored-by: jlheard <1328792+jlheard@users.noreply.github.com>
Created a new commit (4687c25) that updates the CI trigger file. This should re-enable the "Approve and run workflows" button for a repository maintainer with proper permissions to press. |
- Updated ConfigAwsS3DataConnectorScripts.zip - Updated ConfigAwsS3DataConnectorScriptsGov.zip - Changes triggered by: 4687c25 [skip ci]
I don't have the ability to create new PRs. I can only make changes to the current branch (copilot/automate-s3-config-updates) and commit/push them. To create a new PR with the same changes, you would need to:
Alternatively, the "Approve and run workflows" button issue might be resolved by having a repository maintainer with proper permissions close and reopen this PR, which can sometimes reset the approval state. |
|
created a new PR with these changes to get the checks to run: #13390 |
Proposed Changes
.github/workflows/aws-s3-bundle-update.yamlto auto-update bundles on PRs with source file changes, enterprise security features, and resource optimizationDataConnectors/AWS-S3/BUNDLE_AUTOMATION.mdwith comprehensive, future-proof automation documentationDataConnectors/AWS-S3/README.mdto reference automation and include sanity check comment for workflow testingNote: The bundling script
.script/bundleAwsS3Scripts.shalready exists in the master branch and is used by the workflow via script restoration from the base branch for security purposes.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.