From 7c4369d6d4212868134e850a35517ad733ca0316 Mon Sep 17 00:00:00 2001 From: Paras Prajapati <15036233+paraspraj@users.noreply.github.com> Date: Tue, 13 Dec 2022 10:47:50 -0500 Subject: [PATCH] HCE-721 Enable Auto Dependabot Changelogs (#150) * enable dependabot changelogs * changelog * newline --- .changelog/150.txt | 3 ++ .github/dependabot.yml | 4 ++ .../workflows/create-dependabot-changelog.yml | 37 +++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 .changelog/150.txt create mode 100644 .github/workflows/create-dependabot-changelog.yml diff --git a/.changelog/150.txt b/.changelog/150.txt new file mode 100644 index 00000000..478f3229 --- /dev/null +++ b/.changelog/150.txt @@ -0,0 +1,3 @@ +```release-note:improvement +Enable automatic changelog creation for dependabot PRs. +``` \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 07d21d9d..9cf4f95f 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -11,8 +11,12 @@ updates: schedule: # Check for updates to GitHub Actions every weekday interval: "daily" + labels: + - "pr/no-changelog" - package-ecosystem: "gomod" # See documentation for possible values directory: "/" # Location of package manifests schedule: interval: "daily" + labels: + - "pr/no-changelog" diff --git a/.github/workflows/create-dependabot-changelog.yml b/.github/workflows/create-dependabot-changelog.yml new file mode 100644 index 00000000..114dd4a0 --- /dev/null +++ b/.github/workflows/create-dependabot-changelog.yml @@ -0,0 +1,37 @@ +# Auto generate a changelog entry if the PR was opened by dependabot. +--- +name: Create Changelog for Dependabot + +on: + pull_request: + types: + - opened + +jobs: + create_changelog: + runs-on: ubuntu-latest + if: ${{ github.event.pull_request.user.login == 'dependabot'}} + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.ref }} + token: ${{ secrets.HCP_SDK_PIPELINE_TOKEN }} + + - name: Configure git + env: + TOKEN: ${{ secrets.HCP_SDK_PIPELINE_TOKEN }} + run: | + git config --global advice.detachedHead false + git config --global url."https://${TOKEN}:x-oauth-basic@github.com/".insteadOf "https://github.com/" + git config user.name "github-actions" + git config user.email "hashicorp-cloud@hashicorp.com" + - name: Create Changelog + run: | + echo "This is a Dependabot PR. Creating changelog entry on its behalf." + touch .changelog/${{ github.event.pull_request.number }}.txt + printf '```release-note:improvement%s\n' >> .changelog/${{ github.event.pull_request.number }}.txt + printf '${{ github.event.pull_request.title }}%s\n' >> .changelog/${{ github.event.pull_request.number }}.txt + printf '```%s\n' >> .changelog/${{ github.event.pull_request.number }}.txt + git add . + git commit -m "Added changelog entry" + git push