Adding github actions support-3 #3
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 | |
# when to trigger a pipeline | |
on: | |
push: | |
branches: [ "**" ] # "**" it will trigger for any branch, if "*" if branch name contains '/' it will not work | |
# we can have multiple jobs build API, build UI | |
jobs: | |
build-bookmarker-api: | |
name: Build bookmarker-api | |
runs-on: ubuntu-latest # you can specify ubuntu version | |
defaults: | |
run: | |
working-directory: ./bookmarker-api | |
steps: | |
- uses: actions/checkout@v4 # checks out code from github | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' # there are multiple distribution operations. | |
cache: 'maven' | |
- name: Build with Maven | |
run: ./mvnw verify | |
- if: ${{github.ref == 'refs/heads/main' }} | |
name: Build and Publish Docker Image | |
run: | |
./mvwn clean package job:dockerBuild -DskipTests | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker push ${{ secrets.DOCKER_USERNAME }}/bookmarker-api |