Adding workflow dispatch and comment about dockerhub description #115
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 Gradle project | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
- feature* | |
- fix* | |
jobs: | |
build-gradle-project: | |
runs-on: ubuntu-latest | |
env: | |
ALIAS: appsec | |
KEYSTORE: keystore | |
PASSWORD: ${{ secrets.PASSWORD }} | |
CERTIFICATE: ppdt-certificate | |
steps: | |
- name: Checkout project sources | |
uses: actions/checkout@v4 | |
- name: Install Graphviz to visualize trees | |
run: sudo apt-get install -y graphviz | |
- name: Setup Gradle | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'oracle' | |
java-version: '17' | |
cache: 'gradle' | |
- name: Run Gradle Testing and Create Coverage Report | |
run: sh gradlew build -PcreateReports | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
# This workflow uses actions that GitHub does not certify. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
# GitHub recommends pinning actions to a commit SHA. | |
# To get a newer version, you will need to update the SHA. | |
# You can also reference a tag or branch, but the action may change without warning. | |
# https://github.com/docker/build-push-action | |
# Only create a release on main branch | |
upload_dockerhub: | |
# if: github.ref == 'refs/heads/main' | |
# needs: [ build-gradle-project ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout project sources | |
uses: actions/checkout@v4 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: | | |
${{ secrets.DOCKERHUB_USERNAME }}/ppdt:latest | |
# Remember, DockerHub only allows up to 100 characters for the description | |
- name: Docker Hub Description | |
uses: peter-evans/dockerhub-description@v4 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
repository: ${{ secrets.DOCKERHUB_USERNAME }}/ppdt | |
short-description: ${{ github.event.repository.description }} |