Merge pull request #2423 from atlanhq/PLT-290 #2831
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
# | |
# Licensed to the Apache Software Foundation (ASF) under one | |
# or more contributor license agreements. See the NOTICE file | |
# distributed with this work for additional information | |
# regarding copyright ownership. The ASF licenses this file | |
# to you under the Apache License, Version 2.0 (the | |
# "License"); you may not use this file except in compliance | |
# with the License. You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# | |
name: Java CI with Maven | |
on: | |
push: | |
branches: | |
- alpha | |
- beta | |
- development | |
- master | |
- staging | |
- lineageondemand | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up JDK 1.8 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 1.8 | |
- name: Cache Maven packages | |
uses: actions/cache@v2 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/build.sh') }} | |
restore-keys: ${{ runner.os }}-m2 | |
- name: Get branch name | |
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" | |
id: get_branch | |
- name: Build with Maven | |
run: | | |
branch_name=${{ steps.get_branch.outputs.branch }} | |
if [[ $branch_name == 'main' || $branch_name == 'master' || $branch_name == 'lineageondemand' ]] | |
then | |
echo "build without dashboard" | |
chmod +x ./build.sh && ./build.sh build_without_dashboard | |
else | |
echo "build with dashboard" | |
chmod +x ./build.sh && ./build.sh | |
fi | |
- run: echo "REPOSITORY_NAME=`echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//"`" >> $GITHUB_ENV | |
shell: bash | |
- name: Get version tag | |
run: echo "##[set-output name=version;]$(echo `git ls-remote https://${{ secrets.my_pat }}@github.com/atlanhq/${REPOSITORY_NAME}.git refs/heads/${{ steps.get_branch.outputs.branch }} | awk '{ print $1}' | cut -c1-7`)abcd" | |
id: get_version | |
- name: Set up Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to GitHub Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: $GITHUB_ACTOR | |
password: ${{ secrets.my_pat }} | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: ./Dockerfile | |
no-cache: true | |
sbom: true | |
provenance: true | |
push: true | |
tags: | | |
ghcr.io/atlanhq/${{ github.event.repository.name }}-${{ steps.get_branch.outputs.branch }}:latest | |
ghcr.io/atlanhq/${{ github.event.repository.name }}-${{ steps.get_branch.outputs.branch }}:${{ steps.get_version.outputs.version }} | |
- name: Scan Image | |
uses: aquasecurity/trivy-action@master | |
with: | |
image-ref: 'ubuntu:18.04' | |
vuln-type: 'os,library' | |
format: 'sarif' | |
output: 'trivy-image-results.sarif' | |
- name: Upload Trivy scan results to GitHub Security tab | |
uses: github/codeql-action/[email protected] | |
with: | |
sarif_file: 'trivy-image-results.sarif' | |
- name: Check out into atlan repo | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ steps.get_branch.outputs.branch }} | |
repository: atlanhq/atlan | |
token: ${{ secrets.my_pat }} | |
- name: Add Changelog | |
run: | | |
mkdir -p gitlog | |
echo "- ${{ github.event.head_commit.message }}">>gitlog/${{ github.event.repository.name }}.txt | |
chmod +x ./scripts/create_changelog.sh | |
./scripts/create_changelog.sh | |
- name: Commit changes | |
uses: EndBug/add-and-commit@v7 | |
with: | |
branch: ${{ steps.get_branch.outputs.branch }} | |
author_name: atlan-ci | |
author_email: [email protected] | |
message: '${{ github.event.repository.name }}' | |
default_author: user_info | |
push: origin ${{ steps.get_branch.outputs.branch }} |