pre-commit #40
Workflow file for this run
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: Release | |
on: | |
push: | |
tags: | |
- '*' | |
env: | |
REPO_NAME: ${{ github.event.repository.name }} | |
LOWCASE_REPO_NAME: ${{ github.repository_owner}}/heartbeat | |
jobs: | |
build_backend: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./backend | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: ${{ vars.JAVA_VERSION || 19 }} | |
distribution: "adopt" | |
- name: Validate Gradle wrapper | |
uses: gradle/wrapper-validation-action@v3 | |
- name: Set up Gradle | |
uses: gradle/gradle-build-action@v3.5.0 | |
- name: Build | |
run: ./gradlew clean build | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: backend-app | |
path: backend/build/libs/heartbeat-backend-0.0.1-SNAPSHOT.jar | |
retention-days: ${{ vars.RETENTION_DAYS || 10 }} | |
build_frontend: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./frontend | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ vars.NODE_VERSION }} | |
- name: Install | |
run: | | |
npm install -g pnpm | |
pnpm install --no-frozen-lockfile | |
- name: Lint | |
run: pnpm run lint | |
- name: Build | |
run: | | |
pnpm run build | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: frontend-app | |
path: frontend/dist | |
retention-days: ${{ vars.RETENTION_DAYS || 10 }} | |
build_and_push_image: | |
runs-on: ubuntu-latest | |
needs: | |
- build_frontend | |
- build_backend | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get Tag name | |
run: | | |
echo "TAG_NAME=$(git tag --sort version:refname | tail -n 1)" >> "$GITHUB_ENV" | |
- name: Build and Push Docker Image for frontend | |
uses: docker/build-push-action@v6 | |
with: | |
file: ./ops/infra/Dockerfile.frontend | |
push: true | |
tags: | | |
ghcr.io/${{ env.LOWCASE_REPO_NAME }}_frontend:${{ env.TAG_NAME }} | |
ghcr.io/${{ env.LOWCASE_REPO_NAME }}_frontend:latest | |
- name: Build and Push Docker Image for backend | |
uses: docker/build-push-action@v6 | |
with: | |
file: ./ops/infra/Dockerfile.backend | |
push: true | |
tags: | | |
ghcr.io/${{ env.LOWCASE_REPO_NAME }}_backend:${{ env.TAG_NAME }} | |
ghcr.io/${{ env.LOWCASE_REPO_NAME }}_backend:latest | |
build-sbom: | |
runs-on: ubuntu-latest | |
needs: | |
- build_and_push_image | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: anchore/sbom-action@v0 | |
with: | |
path: ./ | |
artifact-name: ${{ env.REPO_NAME }}.${{ env.TAG_NAME }}.sbom.spdx.json | |
- uses: anchore/sbom-action/publish-sbom@v0 | |
release: | |
runs-on: ubuntu-latest | |
needs: | |
- build-sbom | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download frontend artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: frontend-app | |
path: ./${{ env.REPO_NAME }}-frontend | |
- name: Download backend artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: backend-app | |
- name: List | |
run: | | |
ls -a | |
- name: Release | |
id: build | |
run: | | |
mkdir ${{ env.REPO_NAME }} | |
mv ./${{ env.REPO_NAME }}-frontend ${{ env.REPO_NAME }} | |
mv heartbeat-backend-0.0.1-SNAPSHOT.jar ${{ env.REPO_NAME }} | |
zip -r ${{ env.REPO_NAME }}-$(git tag --sort version:refname | tail -n 1).zip ${{ env.REPO_NAME }} | |
ls | |
echo "TAG_NAME=$(git tag --sort version:refname | tail -n 1)" >> "$GITHUB_ENV" | |
- name: Upload zip file | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: ${{ env.REPO_NAME }}-${{ env.TAG_NAME }}.zip |