Quick check to help reduce work in some cases, ain't much, but its ho… #259
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
name: Java CI | |
on: | |
push: | |
branches: | |
- '**' | |
pull_request: | |
types: [ opened, synchronize, reopened ] | |
jobs: | |
build: | |
name: Build for JDK ${{ matrix.java }} | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'DreamExposure/DisCal-Discord-Bot' }} | |
strategy: | |
matrix: | |
java: [ 17 ] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Install NPM | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 14.8.0 | |
- name: Set up JDK ${{ matrix.java }} | |
uses: actions/setup-java@v4 | |
with: | |
java-version: ${{ matrix.java }} | |
distribution: 'adopt' | |
- name: Validate gradle | |
uses: gradle/wrapper-validation-action@v2 | |
- name: Change wrapper permissions | |
run: chmod +x ./gradlew | |
# Build project | |
- name: Build with Gradle | |
run: ./gradlew clean build | |
publish-artifacts: | |
name: Publish Artifacts | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name != 'pull_request' && (github.ref_name == 'develop' || github.ref_name == 'master') }} | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Install NPM | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 14.8.0 | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 17 | |
distribution: 'adopt' | |
- name: Change wrapper permissions | |
run: chmod +x ./gradlew | |
- name: Publish to CR with Gradle | |
uses: Wandalen/wretry.action@master | |
env: | |
SCW_USER: ${{ secrets.SCW_USER }} | |
SCW_SECRET: ${{ secrets.SCW_SECRET }} | |
with: | |
command: ./gradlew clean jib -Djib.to.auth.username=${SCW_USER} -Djib.to.auth.password=${SCW_SECRET} -Djib.console=plain | |
attempt_limit: 25 | |
# 1 minute in ms | |
attempt_delay: 60000 | |
deploy-dev: | |
name: Deploy dev | |
runs-on: ubuntu-latest | |
if: github.ref_name == 'develop' | |
needs: publish-artifacts | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# Have K8S pull latest images for dev pods | |
- name: Trigger dev deploy | |
uses: davi020/kubernetes-action@master | |
env: | |
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }} | |
with: | |
args: delete -n discal pods -l env=dev,app=discal |