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

Update actions #26

Merged
merged 1 commit into from
Jul 25, 2024
Merged

Update actions #26

merged 1 commit into from
Jul 25, 2024

Conversation

allthings-bot
Copy link
Member

@allthings-bot allthings-bot commented Jul 18, 2024

Update actions from workflow

Summary by CodeRabbit

  • New Features
    • Introduced a GitHub Action to manage pipeline status using DynamoDB.
    • Added a GitHub Action for setting up Docker and logging in to Docker Hub.
    • Implemented a GitHub Action for sending customizable Slack notifications.

Copy link

coderabbitai bot commented Jul 18, 2024

Walkthrough

This update introduces three new GitHub Actions: ddb-pipeline-status, which manages and checks pipeline status using DynamoDB; docker-setup, which sets up Docker and logs into Docker Hub; and slack-notifications, which sends Slack notifications based on triggers. Each action is designed to automate specific parts of the CI/CD pipeline to streamline workflows and improve communication.

Changes

File Summary of Changes
.github/actions/ddb-pipeline-status/action.yml Added a new action to change and check pipeline statuses in DynamoDB, including steps to set statuses to "in progress", "passed", or check the status based on inputs. Utilizes environment variables and AWS CLI commands.
.github/actions/docker-setup/action.yml Introduced a new action for setting up Docker, including steps to configure Docker Buildx, QEMU, and Docker Hub login.
.github/actions/slack-notifications/action.yml Created a new action for sending Slack notifications. Defines inputs for notification types and uses a bash script to send messages based on specified triggers, such as nightly security checks.

Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bf75501 and cf09e7a.

Files selected for processing (3)
  • .github/actions/ddb-pipeline-status/action.yml (1 hunks)
  • .github/actions/docker-setup/action.yml (1 hunks)
  • .github/actions/slack-notifications/action.yml (1 hunks)
Files skipped from review due to trivial changes (1)
  • .github/actions/docker-setup/action.yml
Additional comments not posted (6)
.github/actions/slack-notifications/action.yml (3)

1-2: LGTM!

The header correctly defines the name and description of the action.


3-7: LGTM!

The inputs section correctly defines the required input parameter notification-type.


8-23: Ensure secure handling of the Slack webhook URL.

Make sure that SLACK_GITHUB_ACTIONS_WEBHOOK is securely stored as a secret in the GitHub repository settings to prevent exposure.

.github/actions/ddb-pipeline-status/action.yml (3)

1-2: LGTM!

The header correctly defines the name and description of the action.


3-10: LGTM!

The inputs section correctly defines the required input parameters action and project.


11-33: Ensure secure configuration of aws-vault.

Make sure that aws-vault is securely configured to manage AWS credentials.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Comment on lines +21 to +22
curl -X POST "${{ env.SLACK_GITHUB_ACTIONS_WEBHOOK }}" -H "Content-Type: application/json" \
-d "{\"blocks\":[{\"text\":{\"text\":\"*Name:* ${{ env.PROJECT }} nightly security check\\n*Type:* cron-job\\n*Text:* Security check failed\\n><$JOB_URL|View failing job>\",\"type\":\"mrkdwn\"},\"type\":\"section\"}],\"text\":\"\"}"
Copy link

Choose a reason for hiding this comment

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

Improve readability of the curl command.

Break down the long curl command into multiple lines for better readability.

-          curl -X POST "${{ env.SLACK_GITHUB_ACTIONS_WEBHOOK }}" -H "Content-Type: application/json" \
-            -d "{\"blocks\":[{\"text\":{\"text\":\"*Name:* ${{ env.PROJECT }} nightly security check\\n*Type:* cron-job\\n*Text:* Security check failed\\n><$JOB_URL|View failing job>\",\"type\":\"mrkdwn\"},\"type\":\"section\"}],\"text\":\"\"}"        
+          curl -X POST "${{ env.SLACK_GITHUB_ACTIONS_WEBHOOK }}" \
+            -H "Content-Type: application/json" \
+            -d '{
+              "blocks": [
+                {
+                  "text": {
+                    "text": "*Name:* ${{ env.PROJECT }} nightly security check\n*Type:* cron-job\n*Text:* Security check failed\n><$JOB_URL|View failing job>",
+                    "type": "mrkdwn"
+                  },
+                  "type": "section"
+                }
+              ],
+              "text": ""
+            }'
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
curl -X POST "${{ env.SLACK_GITHUB_ACTIONS_WEBHOOK }}" -H "Content-Type: application/json" \
-d "{\"blocks\":[{\"text\":{\"text\":\"*Name:* ${{ env.PROJECT }} nightly security check\\n*Type:* cron-job\\n*Text:* Security check failed\\n><$JOB_URL|View failing job>\",\"type\":\"mrkdwn\"},\"type\":\"section\"}],\"text\":\"\"}"
curl -X POST "${{ env.SLACK_GITHUB_ACTIONS_WEBHOOK }}" \
-H "Content-Type: application/json" \
-d '{
"blocks": [
{
"text": {
"text": "*Name:* ${{ env.PROJECT }} nightly security check\n*Type:* cron-job\n*Text:* Security check failed\n><$JOB_URL|View failing job>",
"type": "mrkdwn"
},
"type": "section"
}
],
"text": ""
}'

Comment on lines +26 to +30
aws-vault exec --backend=pass allthings-development-github-role -- aws dynamodb update-item \
--table-name "${{ env.TABLE_NAME }}" \
--update-expression "SET passed = :status" \
--expression-attribute-values '{":status":{"BOOL":false}}' \
--key="$keyJson"
Copy link

Choose a reason for hiding this comment

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

Improve readability of the DynamoDB update command.

Break down the long DynamoDB update command into multiple lines for better readability.

-          aws-vault exec --backend=pass allthings-development-github-role -- aws dynamodb update-item \
-            --table-name "${{ env.TABLE_NAME }}" \
-            --update-expression "SET passed = :status" \
-            --expression-attribute-values '{":status":{"BOOL":false}}' \
-            --key="$keyJson"
+          aws-vault exec --backend=pass allthings-development-github-role -- \
+            aws dynamodb update-item \
+              --table-name "${{ env.TABLE_NAME }}" \
+              --update-expression "SET passed = :status" \
+              --expression-attribute-values '{":status":{"BOOL":false}}' \
+              --key="$keyJson"
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
aws-vault exec --backend=pass allthings-development-github-role -- aws dynamodb update-item \
--table-name "${{ env.TABLE_NAME }}" \
--update-expression "SET passed = :status" \
--expression-attribute-values '{":status":{"BOOL":false}}' \
--key="$keyJson"
aws-vault exec --backend=pass allthings-development-github-role -- \
aws dynamodb update-item \
--table-name "${{ env.TABLE_NAME }}" \
--update-expression "SET passed = :status" \
--expression-attribute-values '{":status":{"BOOL":false}}' \
--key="$keyJson"

Comment on lines +36 to +54
- name: Set to in passed
env:
BRANCH_NAME: ${{ github.ref_name }}
COMMAND_ACTION: ${{ inputs.action }}
PROJECT: ${{ inputs.project }}
TABLE_NAME: allthings-github-actions-status
shell: bash
run: |
if [ "${{ env.COMMAND_ACTION }}" != "passed" ]; then exit 0; fi

keyJson="{\"pk\":{\"S\":\"${{ env.PROJECT }}-${{ env.BRANCH_NAME }}\"}}"
{
aws-vault exec --backend=pass allthings-development-github-role -- aws dynamodb update-item \
--table-name "${{ env.TABLE_NAME }}" --key="$keyJson" \
--update-expression "SET passed = :status" \
--expression-attribute-values '{":status":{"BOOL":true}}'
} || {
exit 1
}
Copy link

Choose a reason for hiding this comment

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

Improve readability of the DynamoDB update command.

Break down the long DynamoDB update command into multiple lines for better readability.

-          aws-vault exec --backend=pass allthings-development-github-role -- aws dynamodb update-item \
-            --table-name "${{ env.TABLE_NAME }}" --key="$keyJson" \
-            --update-expression "SET passed = :status" \
-            --expression-attribute-values '{":status":{"BOOL":true}}'
+          aws-vault exec --backend=pass allthings-development-github-role -- \
+            aws dynamodb update-item \
+              --table-name "${{ env.TABLE_NAME }}" \
+              --key="$keyJson" \
+              --update-expression "SET passed = :status" \
+              --expression-attribute-values '{":status":{"BOOL":true}}'
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Set to in passed
env:
BRANCH_NAME: ${{ github.ref_name }}
COMMAND_ACTION: ${{ inputs.action }}
PROJECT: ${{ inputs.project }}
TABLE_NAME: allthings-github-actions-status
shell: bash
run: |
if [ "${{ env.COMMAND_ACTION }}" != "passed" ]; then exit 0; fi
keyJson="{\"pk\":{\"S\":\"${{ env.PROJECT }}-${{ env.BRANCH_NAME }}\"}}"
{
aws-vault exec --backend=pass allthings-development-github-role -- aws dynamodb update-item \
--table-name "${{ env.TABLE_NAME }}" --key="$keyJson" \
--update-expression "SET passed = :status" \
--expression-attribute-values '{":status":{"BOOL":true}}'
} || {
exit 1
}
{
aws-vault exec --backend=pass allthings-development-github-role -- \
aws dynamodb update-item \
--table-name "${{ env.TABLE_NAME }}" \
--key="$keyJson" \
--update-expression "SET passed = :status" \
--expression-attribute-values '{":status":{"BOOL":true}}'
} || {
exit 1
}

Comment on lines +57 to +69
- name: Set to in passed
env:
BRANCH_NAME: ${{ github.ref_name }}
COMMAND_ACTION: ${{ inputs.action }}
PROJECT: ${{ inputs.project }}
TABLE_NAME: allthings-github-actions-status
shell: bash
run: |
if [ "${{ env.COMMAND_ACTION }}" != "status" ]; then exit 0; fi

keyJson="{\"pk\":{\"S\":\"${{ env.PROJECT }}-${{ env.BRANCH_NAME }}\"}}"
aws-vault exec --backend=pass allthings-development-github-role -- aws dynamodb get-item \
--table-name "${{ env.TABLE_NAME }}" --key="$keyJson" | grep "\"BOOL\": true" || exit 1
Copy link

Choose a reason for hiding this comment

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

Ensure error handling for the DynamoDB get-item command.

Ensure that errors are handled gracefully when the DynamoDB get-item command fails.

-          aws-vault exec --backend=pass allthings-development-github-role -- aws dynamodb get-item \
-            --table-name "${{ env.TABLE_NAME }}" --key="$keyJson" | grep "\"BOOL\": true" || exit 1
+          aws-vault exec --backend=pass allthings-development-github-role -- \
+            aws dynamodb get-item \
+              --table-name "${{ env.TABLE_NAME }}" \
+              --key="$keyJson" | grep "\"BOOL\": true" || {
+                echo "Error: DynamoDB get-item command failed."
+                exit 1
+              }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Set to in passed
env:
BRANCH_NAME: ${{ github.ref_name }}
COMMAND_ACTION: ${{ inputs.action }}
PROJECT: ${{ inputs.project }}
TABLE_NAME: allthings-github-actions-status
shell: bash
run: |
if [ "${{ env.COMMAND_ACTION }}" != "status" ]; then exit 0; fi
keyJson="{\"pk\":{\"S\":\"${{ env.PROJECT }}-${{ env.BRANCH_NAME }}\"}}"
aws-vault exec --backend=pass allthings-development-github-role -- aws dynamodb get-item \
--table-name "${{ env.TABLE_NAME }}" --key="$keyJson" | grep "\"BOOL\": true" || exit 1
- name: Set to in passed
env:
BRANCH_NAME: ${{ github.ref_name }}
COMMAND_ACTION: ${{ inputs.action }}
PROJECT: ${{ inputs.project }}
TABLE_NAME: allthings-github-actions-status
shell: bash
run: |
if [ "${{ env.COMMAND_ACTION }}" != "status" ]; then exit 0; fi
keyJson="{\"pk\":{\"S\":\"${{ env.PROJECT }}-${{ env.BRANCH_NAME }}\"}}"
aws-vault exec --backend=pass allthings-development-github-role -- \
aws dynamodb get-item \
--table-name "${{ env.TABLE_NAME }}" \
--key="$keyJson" | grep "\"BOOL\": true" || {
echo "Error: DynamoDB get-item command failed."
exit 1
}

@itmustbemagic itmustbemagic merged commit ffbf083 into master Jul 25, 2024
3 checks passed
@itmustbemagic itmustbemagic deleted the actions-spreader-9988257350 branch July 25, 2024 08:18
@coderabbitai coderabbitai bot mentioned this pull request Dec 3, 2024
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