Skip to content

Commit

Permalink
Ta i bruk gjenbrukbar workflow for å publisere pakker på ghpr
Browse files Browse the repository at this point in the history
  • Loading branch information
runska committed Sep 30, 2024
1 parent c3016b3 commit 429ce08
Showing 1 changed file with 6 additions and 64 deletions.
70 changes: 6 additions & 64 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,73 +1,15 @@
name: Build and Deploy
name: Bygg og publiser pakke på GitHub Packages

on:
push:
branches:
- 'main'

jobs:
build:
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: 'gradle'

- uses: gradle/actions/setup-gradle@v3
with:
arguments: build

- name: Post build failures to Slack
if: failure()
run: |
curl -X POST --data "{\"text\": \"Build av $GITHUB_REPOSITORY feilet - $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID\"}" $WEBHOOK_URL
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

release:
name: Create Release
needs: build
runs-on: ubuntu-latest
build_and_deploy:
name: "Opprett og publiser leveranse på GitHub Packages"
uses: navikt/tilleggsstonader/.github/workflows/java-build-and-publish-release.yml@main
secrets: inherit
permissions:
contents: write
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set release tag
run: |
export TAG_NAME="$(TZ="Europe/Oslo" date +%Y.%m.%d-%H.%M).$(git rev-parse --short=12 HEAD)"
echo "RELEASE_TAG=$TAG_NAME" >> $GITHUB_ENV
#- name: Set changelog
# id: changelog
# # (Escape newlines see https://github.com/actions/create-release/issues/25)
# run: |
# text="$(git --no-pager log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"%h %s")"
# echo "::set-output name=CHANGELOG::$text"

- name: Create release
uses: softprops/action-gh-release@v2
with:
name: Release ${{ env.RELEASE_TAG }}
tag_name: ${{ env.RELEASE_TAG }}
draft: false
prerelease: false

- name: Publish
uses: gradle/actions/setup-gradle@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
arguments: -Pversion=${{ env.RELEASE_TAG }} publish

- name: Post release failures to Slack
if: failure()
run: |
curl -X POST --data "{\"text\": \"Release av $GITHUB_REPOSITORY feilet - $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID\"}" $WEBHOOK_URL
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

0 comments on commit 429ce08

Please sign in to comment.