Skip to content

Merge pull request #19 from atilara/develop #27

Merge pull request #19 from atilara/develop

Merge pull request #19 from atilara/develop #27

Workflow file for this run

name: Build and deploy API to Docker Hub
on:
push:
branches:
- master
permissions:
contents: write
jobs:
build-deploy:
environment: production
name: Build and deploy
runs-on: ubuntu-latest
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
DATABASE_USER: ${{ secrets.DATABASE_USER }}
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
JWT_SECRET_KEY: ${{ secrets.JWT_SECRET_KEY }}
steps:
- name: Checkout code
uses: actions/checkout@v2 # Checkout the code in the action workspace, in this case ubuntu-latest
- name: Setup Java JDK
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: 17
- name: Build with Maven
run: |
mvn clean
mvn -B package --file pom.xml -Dmaven.test.skip=true
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
- name: Extract Maven project version
run: echo ::set-output name=version::$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
id: project
- name: Push to Docker Hub
uses: docker/build-push-action@v2
with:
context: .
dockerfile: Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/authentication-jwt-spring-boot:${{ steps.project.outputs.version }}
${{ secrets.DOCKERHUB_USERNAME }}/authentication-jwt-spring-boot:latest
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.project.outputs.version }}
name: v${{ steps.project.outputs.version }}
generateReleaseNotes: true
artifacts: ./target/*.jar