177 lines
5.2 KiB
YAML
177 lines
5.2 KiB
YAML
# 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.
|
|
|
|
# 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.
|
|
|
|
name: "Publish C4PO Docker Hub"
|
|
|
|
on:
|
|
push:
|
|
branches: [ "main" ]
|
|
|
|
env:
|
|
ANGULAR_PATH: security-c4po-angular
|
|
API_PATH: security-c4po-api
|
|
REPORTING_PATH: security-c4po-reporting
|
|
CFG_PATH: security-c4po-cfg
|
|
|
|
jobs:
|
|
|
|
angular_job:
|
|
name: "Angular Job"
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: "Check out code"
|
|
uses: actions/checkout@v3
|
|
|
|
- name: "Use Node.js 14.x"
|
|
uses: actions/setup-node@v1
|
|
with:
|
|
node-version: '14.x'
|
|
cache: 'npm'
|
|
|
|
- name: "Install NPM dependencies"
|
|
run: |
|
|
cd $ANGULAR_PATH
|
|
npm ci
|
|
|
|
- name: "Build assets"
|
|
run: |
|
|
cd $ANGULAR_PATH
|
|
npm run build --if-present
|
|
|
|
- name: "Run tests"
|
|
run: |
|
|
cd $ANGULAR_PATH
|
|
npm test
|
|
|
|
api_job:
|
|
name: "API Job"
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: "Check out code"
|
|
uses: actions/checkout@v3
|
|
|
|
- name: "Set up JDK 11"
|
|
uses: actions/setup-java@v3
|
|
with:
|
|
java-version: '11'
|
|
distribution: 'temurin'
|
|
|
|
- name: "Setup Gradle"
|
|
uses: gradle/gradle-build-action@v2
|
|
with:
|
|
gradle-version: 6.5
|
|
|
|
- name: "Execute Gradle build"
|
|
run: |
|
|
cd $API_PATH
|
|
./gradlew clean bootJar -x dependencyCheckAnalyze
|
|
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: API-jar
|
|
path: security-c4po-api/build/libs/security-c4po-api-0.0.1-SNAPSHOT.jar # artifacts/api.jar
|
|
|
|
reporting_job:
|
|
name: "Reporting Job"
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: "Check out code"
|
|
uses: actions/checkout@v3
|
|
|
|
- name: "Set up JDK 11"
|
|
uses: actions/setup-java@v3
|
|
with:
|
|
java-version: '11'
|
|
distribution: 'temurin'
|
|
|
|
- name: "Setup Gradle"
|
|
uses: gradle/gradle-build-action@v2
|
|
with:
|
|
gradle-version: 6.5
|
|
|
|
- name: "Execute Gradle build"
|
|
run: |
|
|
cd $REPORTING_PATH
|
|
./gradlew clean bootJar
|
|
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: REPORTING-jar
|
|
path: security-c4po-reporting/build/libs/security-c4po-reporting-0.0.1-SNAPSHOT.jar # artifacts/reporting.jar
|
|
|
|
push_c4po_to_docker_hub:
|
|
name: "Push images to Docker Hub"
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: [angular_job, api_job, reporting_job]
|
|
|
|
steps:
|
|
- name: "Check out the repo"
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Download jar api artifact
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: API-jar
|
|
path: security-c4po-api/build/libs/security-c4po-api-0.0.1-SNAPSHOT.jar
|
|
|
|
- name: Download jar reporting artifact
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: REPORTING-jar
|
|
path: security-c4po-reporting/build/libs/security-c4po-reporting-0.0.1-SNAPSHOT.jar
|
|
|
|
- name: "Set up Docker Compose"
|
|
# https://github.com/marketplace/actions/docker-compose-action
|
|
uses: isbang/compose-action@v1.4.1
|
|
with:
|
|
compose-file: ./security-c4po-cfg/docker-compose.yml
|
|
|
|
- name: "Build Docker images"
|
|
run: |
|
|
cd $CFG_PATH
|
|
docker-compose build \
|
|
--build-arg TAG=c4po:${{ github.run_number }} \
|
|
--build-arg VERSION=c4po:${{ github.run_number }} \
|
|
--build-arg JAR_FILE_API=security-c4po-api/build/libs/security-c4po-api-0.0.1-SNAPSHOT.jar \
|
|
--build-arg JAR_FILE_REPORT=security-c4po-reporting/build/libs/security-c4po-reporting-0.0.1-SNAPSHOT.jar
|
|
|
|
- name: "Log in to Docker Hub"
|
|
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
|
|
with:
|
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
|
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
|
|
|
- name: "Extract metadata (tags, labels) for Docker"
|
|
id: meta
|
|
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
|
|
with:
|
|
images: cellecram/security-c4po # my-docker-hub-namespace/my-docker-hub-repository
|
|
|
|
- name: "Push Docker images"
|
|
run: |
|
|
docker image ls
|
|
docker image tag security-c4po-angular cellecram/security-c4po:angular
|
|
docker image push cellecram/security-c4po:angular
|
|
docker image tag security-c4po-api cellecram/security-c4po:api
|
|
docker image push cellecram/security-c4po:api
|
|
docker image tag security-c4po-reporting cellecram/security-c4po:reporting
|
|
docker image push cellecram/security-c4po:reporting
|
|
docker image tag quay.io/keycloak/keycloak:20.0.0 cellecram/security-c4po:keycloak
|
|
docker image push cellecram/security-c4po:keycloak
|
|
docker image tag mongo:5.0.0-focal cellecram/security-c4po:mongo
|
|
docker image push cellecram/security-c4po:mongo
|