Skip to content

Commit

Permalink
Oppdaterer workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
anders-nom committed Dec 19, 2024
1 parent 76e3872 commit 29edd00
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 20 deletions.
7 changes: 3 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ updates:
directory: "/"
schedule:
interval: daily
# set limit to 1 as auto-merge seems to fail if more than 1
open-pull-requests-limit: 1
open-pull-requests-limit: 10
assignees:
- "@navikt/tpts"
# arrow 2.0 brekker integrasjon med jackson i mange apper
# arrow 2.0 brekker integrasjon med jackson i saksbehandling-api (og kanskje andre?)
# TODO: fjern ignore når dette er fikset:
# https://github.com/arrow-kt/arrow-integrations/issues/126
# https://youtrack.jetbrains.com/issue/KT-72084/Reflection-ISE-This-is-should-be-simple-type-for-inline-class-with-delegated-Java-interface
Expand All @@ -19,6 +18,6 @@ updates:
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 15
open-pull-requests-limit: 10
assignees:
- "@navikt/tpts"
43 changes: 30 additions & 13 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Dependabot auto-merge
on: pull_request
on:
pull_request:
branches:
- main

permissions:
contents: write
Expand All @@ -9,35 +12,49 @@ jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
env:
PR_SHA: ${{ github.event.pull_request.head.sha }}
WEBHOOK_URL: ${{ secrets.SLACK_VARSEL_WEBHOOK_URL }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Fetch dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Notify Slack on new major version and abort
if: steps.metadata.outputs.update-type == 'version-update:semver-major' && steps.metadata.outputs.package-ecosystem != 'github_actions'
id: major
run: |
curl -X POST --data-urlencode "payload={ \"attachments\": [{ \"pretext\": \"[${{ github.event.repository.name }}] Ny major dependency versjon!\", \"color\": \"info\", \"fields\": [ { \"title\": \"Commit\", \"value\": \"<https://github.com/${{ github.repository }}/commit/$PR_SHA|$PR_SHA>\", \"short\": false }, { \"title\": \"Dependency\", \"value\": \"$DEPENDENCY_NAME $VERSION_CHANGE\", \"short\": false } ] }] }" $WEBHOOK_URL
exit 1
env:
DEPENDENCY_NAME: ${{ steps.metadata.outputs.dependency-names }}
VERSION_CHANGE: "${{ steps.metadata.outputs.previous-version }} -> ${{ steps.metadata.outputs.new-version }}"
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
if: steps.metadata.outputs.package-ecosystem != 'github_actions'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
if: steps.metadata.outputs.package-ecosystem != 'github_actions'
- name: Build and run tests
run: ./gradlew build
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
id: build
if: steps.metadata.outputs.package-ecosystem != 'github_actions'
- name: Auto-merge changes from Dependabot
if: steps.metadata.outputs.update-type != 'version-update:semver-major' || steps.metadata.outputs.package-ecosystem == 'github_actions'
run: gh pr merge --auto --squash "$PR_URL"
id: merge
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Notify Slack in case of merge failure
if: failure()
if: failure() && steps.major.conclusion == 'skipped'
run: |
curl -X POST --data-urlencode "payload={ \"attachments\": [{ \"pretext\": \"[${{ github.event.repository.name }}] Merge failed :cry:\", \"color\": \"danger\", \"fields\": [ { \"title\": \"Author\", \"value\": \"$AUTHOR\", \"short\": false }, { \"title\": \"Branch\", \"value\": \"$BRANCH\", \"short\": false }, { \"title\": \"Commit\", \"value\": \"<https://github.com/${{ github.repository }}/commit/$PR_SHA|$PR_SHA>\", \"short\": false } ] }] }" $WEBHOOK_URL
curl -X POST --data-urlencode "payload={ \"attachments\": [{ \"pretext\": \"[${{ github.event.repository.name }}] Dependabot auto-merge failed :cry:\", \"color\": \"danger\", \"fields\": [ { \"title\": \"Commit\", \"value\": \"<https://github.com/${{ github.repository }}/commit/$PR_SHA|$PR_SHA>\", \"short\": false }, { \"title\": \"Dependency\", \"value\": \"$DEPENDENCY_NAME $VERSION_CHANGE\", \"short\": false } ] }] }" $WEBHOOK_URL
env:
PR_SHA: ${{ github.event.pull_request.head.sha }}
BRANCH: ${{ github.head_ref }}
AUTHOR: ${{ github.actor }}
WEBHOOK_URL: ${{ secrets.SLACK_TP_VARSEL_WEBHOOK_URL }}
DEPENDENCY_NAME: ${{ steps.metadata.outputs.dependency-names }}
VERSION_CHANGE: "${{ steps.metadata.outputs.previous-version }} -> ${{ steps.metadata.outputs.new-version }}"
23 changes: 23 additions & 0 deletions .github/workflows/notify-on-main-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Post slack notification on pull request

on:
pull_request:
types:
- opened
- reopened
branches:
- main

jobs:
notify:
name: Notify tiltakspenger-pull-requests
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]'
steps:
- name: Post message
env:
WEBHOOK_URL: ${{ secrets.SLACK_PR_WEBHOOK_URL }}
PR_TITLE: ${{ github.event.pull_request.title }}
PR_URL: ${{ github.server_url }}/${{ github.repository }}/pull/${{ github.event.pull_request.number }}
run: |
curl -X POST --data "{\"text\": \"Pull request åpnet: $GITHUB_ACTOR på $GITHUB_REPOSITORY - $PR_URL - $PR_TITLE\"}" $WEBHOOK_URL
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
name: Post slack notification on main push

on: push
on:
push:
branches:
- main

jobs:
notify:
name: Notify tiltakspenger-pull-requests
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' && !startsWith(github.event.head_commit.message, 'Merge pull request') && github.actor != 'dependabot[bot]' }}
if: github.actor != 'dependabot[bot]'
steps:
- name: Post message
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
WEBHOOK_URL: ${{ secrets.SLACK_PR_WEBHOOK_URL }}
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: |
curl -X POST --data "{\"text\": \"Push til main: $GITHUB_ACTOR på $GITHUB_REPOSITORY - $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/$GITHUB_SHA - ${{ env.COMMIT_MESSAGE }}\"}" $WEBHOOK_URL

0 comments on commit 29edd00

Please sign in to comment.