Skip to content

chore: add Jira automation workflows #176

chore: add Jira automation workflows

chore: add Jira automation workflows #176

name: Dependabot Auto-Approve
on: pull_request
permissions:
pull-requests: write
contents: write
env:
CARGO_ABOUT_VERSION: 0.8.2
jobs:
auto-approve:
runs-on: ubuntu-latest
if: |
github.repository == 'mongodb-js/atlas-local-lib-js' &&
github.event.pull_request.user.login == 'dependabot[bot]'
steps:
- name: Set Apix Bot token
id: app-token
uses: mongodb/apix-action/token@8549161120ce38b1e132ff833302a0ecbde58038
with:
app-id: ${{ secrets.APIXBOT_APP_ID }}
private-key: ${{ secrets.APIXBOT_APP_PEM }}
- name: Checkout PR
uses: actions/checkout@v7
with:
token: ${{ steps.app-token.outputs.token }}
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Install Rust toolchain
run: |
rustup update stable
rustup default stable
- name: Cache cargo tools
uses: actions/cache@v6
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-tools-about-${{ env.CARGO_ABOUT_VERSION }}
restore-keys: |
${{ runner.os }}-cargo-tools-
- name: Install cargo-about
run: |
if ! command -v cargo-about &> /dev/null; then
cargo install --locked --version ${{ env.CARGO_ABOUT_VERSION }} cargo-about
fi
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Update third-party licenses
if: steps.metadata.outputs.package-ecosystem == 'cargo'
run: |
# Generate updated LICENSE-3RD-PARTY.txt
cargo about generate about.hbs > LICENSE-3RD-PARTY.txt
# Check if there are changes to commit
if ! git diff --quiet LICENSE-3RD-PARTY.txt; then
git config --local user.email "${{ steps.app-token.outputs.user-email }}"
git config --local user.name "${{ steps.app-token.outputs.user-name }}"
git add LICENSE-3RD-PARTY.txt
git commit -m "chore(deps): update LICENSE-3RD-PARTY.txt"
git push
echo "Updated LICENSE-3RD-PARTY.txt"
else
echo "LICENSE-3RD-PARTY.txt is already up to date"
fi
- name: Approve Dependabot PR
if: steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor' || contains(steps.metadata.outputs.dependency-names, 'security') || steps.metadata.outputs.package-ecosystem == 'github_actions'
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Enable auto-merge for Dependabot PR
if: steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor' || contains(steps.metadata.outputs.dependency-names, 'security') || steps.metadata.outputs.package-ecosystem == 'github_actions'
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ steps.app-token.outputs.token }}