Skip to content

Try build manually

Try build manually #26

Workflow file for this run

# 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: Java CI with Maven
# When will the action run
on:
push:
branches: [ "testGitHub-Action" ]
pull_request:
branches: [ "testGitHub-Action" ]
jobs:
# build the project
build:
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
- 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/bu-secondhand-1.0.0.jar
# build a docker image and push it to Docker Hub
deploy:
needs: [build]
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/bu-secondhand-1.0.0.jar
- 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
# uses: docker/build-push-action@v6
# with:
# context: ./code/backend
# file: ./code/backend/Dockerfile
# load: true
# push: false
# tags: ${{ vars.DOCKERHUB_USERNAME }}/campus_exchange:latest
- name: Build docker
run: |
docker build -t ${{ vars.DOCKERHUB_USERNAME }}/campus_exchange:latest ./code/backend
- name: Test Docker
run: |
docker run --rm ${{ vars.DOCKERHUB_USERNAME }}/campus_exchange:latest
# - name: Push
# uses: docker/build-push-action@v6
# with:
# context: ./code/backend/
# file: ./code/backend/Dockerfile
# push: true
# tags: ${{ vars.DOCKERHUB_USERNAME }}/campus_exchange:latest