Merge pull request #74 from ssu-commerce/feature/local-config #109
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: Build | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 11 | |
- name: Cache SonarQube packages | |
uses: actions/cache@v1 | |
with: | |
path: ~/.sonar/cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Cache Gradle packages | |
uses: actions/cache@v1 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | |
restore-keys: ${{ runner.os }}-gradle | |
- name: Docker Login | |
run: echo "${{ secrets.TOKEN }}" | docker login ghcr.io -u ${{ secrets.USERNAME }} --password-stdin | |
- name: Build with Gradle | |
env: | |
USERNAME: ${{secrets.USERNAME}} | |
TOKEN: ${{secrets.TOKEN}} | |
GITHUB_TOKEN: ${{ secrets.TOKEN }} # Needed to get PR information, if any | |
run: ./gradlew clean test jacocoTestReport --stacktrace --profile | |
- name: SonarQube Scan | |
uses: sonarsource/sonarqube-scan-action@master | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} | |
- name: Set Current Time | |
uses: 1466587594/get-current-time@v1 | |
id: current-time | |
with: | |
format: YYYY.MM | |
utcOffset: "+09:00" | |
if: always() | |
- name: Build with Gradle and Jib | |
env: | |
VERSION: "${{ steps.current-time.outputs.formattedTime }}.${{github.run_number}}" | |
USERNAME: ${{secrets.USERNAME}} | |
TOKEN: ${{secrets.TOKEN}} | |
GITHUB_TOKEN: ${{ secrets.TOKEN }} # Needed to get PR information, if any | |
run: ./gradlew :api:jib | |
deploy: | |
name: Deploy | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the target repository | |
uses: actions/checkout@v4 | |
with: | |
repository: ssu-commerce/helm-charts | |
token: ${{ secrets.HELM_TOKEN }} | |
path: helm-charts | |
- name: Set Current Time | |
uses: 1466587594/get-current-time@v1 | |
id: current-time | |
with: | |
format: YYYY.MM | |
utcOffset: "+09:00" | |
if: always() | |
- name: Update YAML file | |
run: | | |
yq eval '.book.image.tag = "${{ steps.current-time.outputs.formattedTime }}.${{github.run_number}}"' -i helm-charts/chart/ssu-commerce/values.yaml | |
- name: Commit changes | |
run: | | |
cd helm-charts | |
git config --local user.name "github-actions[bot]" | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git add chart/ssu-commerce/values.yaml | |
git commit -m 'Update image tag to ${{ steps.current-time.outputs.formattedTime }}.${{github.run_number}}' | |
git push origin main |