fix: Set GH_TOKEN for GitHub CLI authentication #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create Issue from Dependabot Alert | |
on: | |
schedule: | |
- cron: '0 0 * * *' # Runs daily at midnight | |
push: | |
branches: | |
- main | |
- develop | |
jobs: | |
create-issue: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Install Dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y jq gh | |
shell: bash | |
- name: Authenticate GitHub CLI | |
run: | | |
echo "${{ secrets.PAT }}" | gh auth login --with-token | |
shell: bash | |
- name: Create Issue from Dependabot Alert | |
run: | | |
# Fetch the latest Dependabot alerts | |
alerts=$(gh api -H "Accept: application/vnd.github.v3+json" /repos/${{ github.repository }}/dependabot/alerts) | |
for alert in $(echo "${alerts}" | jq -r '.[] | @base64'); do | |
_jq() { | |
echo ${alert} | base64 --decode | jq -r ${1} | |
} | |
title=$(_jq '.security_advisory.summary') | |
description=$(_jq '.security_advisory.description') | |
package_name=$(_jq '.security_vulnerability.package.name') | |
# Create a new GitHub issue | |
gh issue create --title "Update $package_name to fix $title" --body "$description" | |
done | |
env: | |
GH_TOKEN: ${{ secrets.PAT }} |