generated from kestra-io/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(cicd): move to reusable workflows on github actions
- Loading branch information
1 parent
ad72632
commit 54cf850
Showing
2 changed files
with
13 additions
and
142 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
echo $GOOGLE_SERVICE_ACCOUNT | base64 -d > ~/.gcp-service-account.json | ||
echo "GOOGLE_APPLICATION_CREDENTIALS=$HOME/.gcp-service-account.json" > $GITHUB_ENV |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name: Main | |
|
||
on: | ||
schedule: | ||
- cron: '0 4 * * 1,3,5' | ||
- cron: '0 4 * * 1,2,3,4,5' | ||
push: | ||
branches: | ||
- master | ||
|
@@ -17,147 +17,16 @@ on: | |
inputs: | ||
skip-test: | ||
description: 'Skip test' | ||
required: false | ||
type: string | ||
default: "false" | ||
type: choice | ||
required: true | ||
default: 'false' | ||
options: | ||
- "true" | ||
- "false" | ||
|
||
jobs: | ||
check: | ||
name: Check & Publish | ||
runs-on: ubuntu-latest | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
GOOGLE_SERVICE_ACCOUNT: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
# Caches | ||
- name: Gradle cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle*.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
# JDK | ||
- name: Set up JDK | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'temurin' | ||
java-version: 21 | ||
|
||
- name: Validate Gradle wrapper | ||
uses: gradle/actions/wrapper-validation@v4 | ||
|
||
# Gradle check | ||
- name: Build with Gradle | ||
if: ${{ github.event.inputs.skip-test == 'false' || github.event.inputs.skip-test == '' }} | ||
env: | ||
GOOGLE_SERVICE_ACCOUNT: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }} | ||
run: | | ||
echo $GOOGLE_SERVICE_ACCOUNT | base64 -d > ~/.gcp-service-account.json | ||
export GOOGLE_APPLICATION_CREDENTIALS=$HOME/.gcp-service-account.json | ||
./gradlew check --refresh-dependencies | ||
# Allure check | ||
- name: Auth to Google Cloud | ||
id: auth | ||
if: ${{ always() && env.GOOGLE_SERVICE_ACCOUNT != 0 }} | ||
uses: 'google-github-actions/auth@v2' | ||
with: | ||
credentials_json: '${{ secrets.GOOGLE_SERVICE_ACCOUNT }}' | ||
|
||
- uses: rlespinasse/github-slug-action@v5 | ||
|
||
- name: Publish allure report | ||
uses: andrcuns/[email protected] | ||
if: ${{ always() && env.GOOGLE_SERVICE_ACCOUNT != 0 && (github.event.inputs.skip-test == 'false' || github.event.inputs.skip-test == '') }} | ||
env: | ||
GITHUB_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
JAVA_HOME: /usr/lib/jvm/default-jvm/ | ||
with: | ||
storageType: gcs | ||
resultsGlob: build/allure-results | ||
bucket: internal-kestra-host | ||
baseUrl: "https://internal.dev.kestra.io" | ||
prefix: ${{ format('{0}/{1}', github.repository, 'allure/java') }} | ||
copyLatest: true | ||
ignoreMissingResults: true | ||
|
||
# Jacoco | ||
- name: 'Set up Cloud SDK' | ||
if: ${{ env.GOOGLE_SERVICE_ACCOUNT != 0 }} | ||
uses: 'google-github-actions/setup-gcloud@v2' | ||
|
||
- name: 'Copy jacoco files' | ||
if: ${{ env.GOOGLE_SERVICE_ACCOUNT != 0 }} | ||
run: | | ||
gsutil -m rsync -d -r build/reports/jacoco/test/ gs://internal-kestra-host/${{ format('{0}/{1}', github.repository, 'jacoco') }} | ||
# Publish | ||
- name: Publish package to Sonatype | ||
if: github.ref == 'refs/heads/master' | ||
env: | ||
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USER }} | ||
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }} | ||
SONATYPE_GPG_KEYID: ${{ secrets.SONATYPE_GPG_KEYID }} | ||
SONATYPE_GPG_PASSWORD: ${{ secrets.SONATYPE_GPG_PASSWORD }} | ||
SONATYPE_GPG_FILE: ${{ secrets.SONATYPE_GPG_FILE }} | ||
run: | | ||
echo "signing.keyId=${SONATYPE_GPG_KEYID}" > ~/.gradle/gradle.properties | ||
echo "signing.password=${SONATYPE_GPG_PASSWORD}" >> ~/.gradle/gradle.properties | ||
echo "signing.secretKeyRingFile=${HOME}/.gradle/secring.gpg" >> ~/.gradle/gradle.properties | ||
echo ${SONATYPE_GPG_FILE} | base64 -d > ~/.gradle/secring.gpg | ||
./gradlew publishToSonatype | ||
# Release | ||
- name: Release package to Maven Central | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
env: | ||
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USER }} | ||
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }} | ||
SONATYPE_GPG_KEYID: ${{ secrets.SONATYPE_GPG_KEYID }} | ||
SONATYPE_GPG_PASSWORD: ${{ secrets.SONATYPE_GPG_PASSWORD }} | ||
SONATYPE_GPG_FILE: ${{ secrets.SONATYPE_GPG_FILE }} | ||
run: | | ||
echo "signing.keyId=${SONATYPE_GPG_KEYID}" > ~/.gradle/gradle.properties | ||
echo "signing.password=${SONATYPE_GPG_PASSWORD}" >> ~/.gradle/gradle.properties | ||
echo "signing.secretKeyRingFile=${HOME}/.gradle/secring.gpg" >> ~/.gradle/gradle.properties | ||
echo ${SONATYPE_GPG_FILE} | base64 -d > ~/.gradle/secring.gpg | ||
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository | ||
# GitHub Release | ||
- name: Create GitHub release | ||
uses: "marvinpinto/action-automatic-releases@latest" | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
with: | ||
repo_token: "${{ secrets.GITHUB_TOKEN }}" | ||
prerelease: false | ||
files: | | ||
build/libs/*.jar | ||
# Slack | ||
- name: Slack notification | ||
uses: 8398a7/action-slack@v3 | ||
if: ${{ always() && env.SLACK_WEBHOOK_URL != 0 }} | ||
with: | ||
status: ${{ job.status }} | ||
job_name: Check & Publish | ||
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took | ||
username: Github Actions | ||
icon_emoji: ':github-actions:' | ||
channel: 'C02DQ1A7JLR' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
|
||
- name: Notify failed CI | ||
id: send-ci-failed | ||
if: always() && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') && job.status != 'success' | ||
uses: kestra-io/actions/.github/actions/send-ci-failed@main | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
uses: kestra-io/actions/.github/workflows/plugins.yml@main | ||
with: | ||
skip-test: ${{ github.event.inputs.skip-test == 'true' }} | ||
secrets: inherit |