Update maven.yml #36
Workflow file for this run
This file contains hidden or 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
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven | |
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
# Action name | |
name: Test Java CI with Maven | |
# When will the action run | |
on: | |
push: | |
branches: [ "testGitHub-Action" ] | |
pull_request: | |
branches: [ "testGitHub-Action" ] | |
jobs: | |
build-frontend: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./code/frontend | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up npm | |
uses: actions/setup-node@v4 | |
- run: npm ci | |
- run: npm run build | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: frontend | |
path: ./code/frontend/dist/ | |
# build the project | |
build-backend: | |
needs: [build-frontend] | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./code/backend | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: maven | |
- run: ls -R ./code/backend/src/main/resource/static/ | |
- name: download frontend | |
uses: actions/download-artifact@v4 | |
with: | |
name: frontend | |
path: ./code/backend/src/main/resource/static/ | |
- run: ls -R ./code/backend/src/main/resource/static/ | |
- name: Build with Maven | |
run: mvn clean package --file pom.xml | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: bu-secondhand-1.0.0 | |
path: ./code/backend/target/ | |
# build a docker image and push it to Docker Hub | |
deploy: | |
needs: [build-backend] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: bu-secondhand-1.0.0 | |
path: ./code/backend/target/ | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ vars.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and Push docker | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./code/backend | |
file: ./code/backend/Dockerfile | |
push: true | |
tags: ${{ vars.DOCKERHUB_USERNAME }}/campus_exchange:latest |