Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@ updates:
schedule:
interval: "weekly"

- package-ecosystem: "npm"
directory: "/cdk"
schedule:
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/cdk"
schedule:
interval: "weekly"
23 changes: 20 additions & 3 deletions .github/workflows/dependabot-automerge.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Dependabot auto-merge
on: pull_request
on:
workflow_run:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

issue: we should not use workflow run. It runs in a privileged context, and I think can be triggered from fork PRs. The user could add a malicious GitHub Actions workflow (or make a change to this one) and it would run with access to our secrets.

Image

https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#workflow_run

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

oh, I was not aware of the --auto behavior. I was assuming it would try to merge right away, as it was the current behavior. Now your flow makes sense. 👍

workflows: ["Test AppSync utils"]
types:
- completed

permissions:
contents: write
Expand All @@ -15,8 +19,21 @@ jobs:
uses: dependabot/fetch-metadata@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Enable auto-merge for Dependabot PRs
if: ${{ github.event.workflow_run.conclusion == 'success' }}
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Comment on PR if tests failed
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
run: |
gh pr comment "$PR_URL" --body "🚫 Auto-merge skipped: one or more test jobs failed.

Please review the failing checks and resolve any issues.
"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15 changes: 9 additions & 6 deletions .github/workflows/test-appsync-utils.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ on:
workflow_dispatch:

env:
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_API_KEY }}
TEST_IMAGE_NAME: public.ecr.aws/lambda/nodejs:18
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
NODEJS_IMAGE_NAME: public.ecr.aws/lambda/nodejs
NODE_VERSION: 22

jobs:
unit-test:
Expand All @@ -20,7 +21,7 @@ jobs:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 18
node-version: ${{ env.NODE_VERSION }}
- run: npm ci
- run: npm test

Expand All @@ -30,10 +31,10 @@ jobs:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 18
node-version: ${{ env.NODE_VERSION }}

- name: Pull test docker image
run: docker pull $TEST_IMAGE_NAME
run: docker pull ${{ env.NODEJS_IMAGE_NAME }}:${{ env.NODE_VERSION }}

- name: Install dependencies
run: npm ci
Expand All @@ -51,13 +52,15 @@ jobs:
image-tag: "latest"
use-pro: "true"
env:
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_API_KEY }}
LOCALSTACK_AUTH_TOKEN: ${{ env.LOCALSTACK_AUTH_TOKEN }}
APPSYNC_JS_LIBS_VERSION: ${{ github.sha }}
DEBUG: "1"
DISABLE_EVENTS: "1"
- name: Ensure pro image is used
run: curl -s http://localhost:4566/_localstack/health | grep appsync
- uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
- name: Execute test script
run: bash .github/execute-localstack-test.sh
- name: Get the LocalStack logs
Expand Down
Loading