Skip to content

Commit

Permalink
CI: Tweaks to improve security
Browse files Browse the repository at this point in the history
Mostly storing some uncontrolled inputs into intermediate environment
variables to avoid some template injection issues.
  • Loading branch information
dopplershift committed Dec 6, 2024
1 parent 25c523d commit e98a5a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/automerge-dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Auto-merge Dependabot PRs

on:
pull_request_target:
branches: [main]

jobs:
#
Expand All @@ -12,13 +13,15 @@ jobs:
if: github.actor == 'dependabot[bot]'
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
GH_PR: ${{ github.event.pull_request.number }}

permissions:
contents: write
pull-requests: write

steps:
- name: Set auto-merge
run: gh pr merge -R ${{ github.repository }} --merge --auto ${{ github.event.pull_request.number }}
run: gh pr merge -R "$GH_REPO" --merge --auto "$GH_PR"
- name: Review PR
run: gh pr review -R ${{ github.repository }} --approve ${{ github.event.pull_request.number }}
run: gh pr review -R "$GH_REPO" --approve "$GH_PR"
7 changes: 5 additions & 2 deletions .github/workflows/backport-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ jobs:
permissions:
pull-requests: write
contents: write
env:
GH_BASE_SHA: ${{ github.event.pull_request.base.sha }}
GH_HEAD_SHA: ${{ github.event.pull_request.head.sha }}

steps:
- name: Checkout PR HEAD
Expand All @@ -22,7 +25,7 @@ jobs:
fetch-depth: 100

- name: Fetch PR merge base
run: git fetch --no-tags --depth=100 origin ${{ github.event.pull_request.base.sha }}
run: git fetch --no-tags --depth=100 origin "$GH_BASE_SHA"

- name: Set up git
run: |
Expand All @@ -38,7 +41,7 @@ jobs:
- name: Apply PR commits to ${{ steps.get-branch.outputs.backport-branch}} branch
run: |
git checkout -b ${{ steps.get-branch.outputs.backport-branch}} origin/${{ steps.get-branch.outputs.backport-branch}}
git cherry-pick -x ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
git cherry-pick -x "$GH_BASE_SHA".."$GH_HEAD_SHA"
- name: Create backport PR
id: create-pr
Expand Down

0 comments on commit e98a5a9

Please sign in to comment.