Skip to content

Commit 982deac

Browse files
authored
Merge pull request #2 from DevSecOpsSamples/develop
2 parents 1c3395e + ea6a796 commit 982deac

35 files changed

+1436
-15
lines changed

.github/workflows/build.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build & Sonarqube
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- develop
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
10+
jobs:
11+
sonarqube:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Set up JDK 11
16+
uses: actions/setup-java@v1
17+
with:
18+
java-version: 11
19+
- name: Cache Gradle packages
20+
uses: actions/cache@v3
21+
with:
22+
path: |
23+
~/.gradle/caches
24+
~/.gradle/wrapper
25+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties') }}
26+
restore-keys: ${{ runner.os }}-gradle
27+
- name: Cache SonarCloud packages
28+
uses: actions/cache@v3
29+
with:
30+
path: ~/.sonar/cache
31+
key: ${{ runner.os }}-sonar
32+
restore-keys: ${{ runner.os }}-sonar
33+
- name: Build and analyze
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
37+
run: ./gradlew build sonarqube --info

.gitignore

Lines changed: 146 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
# Compiled class file
2-
*.class
1+
build
2+
bin
3+
.gradle
4+
.vscode
5+
.idea
36

4-
# Log file
57
*.log
6-
7-
# BlueJ files
8-
*.ctxt
9-
10-
# Mobile Tools for Java (J2ME)
11-
.mtj.tmp/
12-
13-
# Package Files #
148
*.jar
159
*.war
1610
*.nar
@@ -19,5 +13,144 @@
1913
*.tar.gz
2014
*.rar
2115

22-
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23-
hs_err_pid*
16+
# MAC
17+
.DS_Store
18+
19+
# internal
20+
*internal*
21+
22+
# GCP
23+
## .sa .readonly-sa
24+
.*sa
25+
## google-github-actions/auth@v1
26+
gha-creds-*.json
27+
28+
# Byte-compiled / optimized / DLL files
29+
__pycache__/
30+
*.py[cod]
31+
*$py.class
32+
33+
# C extensions
34+
*.so
35+
36+
# Distribution / packaging
37+
.Python
38+
build/
39+
develop-eggs/
40+
dist/
41+
downloads/
42+
eggs/
43+
.eggs/
44+
lib/
45+
lib64/
46+
parts/
47+
sdist/
48+
var/
49+
wheels/
50+
pip-wheel-metadata/
51+
share/python-wheels/
52+
*.egg-info/
53+
.installed.cfg
54+
*.egg
55+
MANIFEST
56+
57+
# PyInstaller
58+
# Usually these files are written by a python script from a template
59+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
60+
*.manifest
61+
*.spec
62+
63+
# Installer logs
64+
pip-log.txt
65+
pip-delete-this-directory.txt
66+
67+
# Unit test / coverage reports
68+
htmlcov/
69+
.tox/
70+
.nox/
71+
.coverage
72+
.coverage.*
73+
.cache
74+
nosetests.xml
75+
coverage.xml
76+
*.cover
77+
*.py,cover
78+
.hypothesis/
79+
.pytest_cache/
80+
81+
# Translations
82+
*.mo
83+
*.pot
84+
85+
# Django stuff:
86+
*.log
87+
local_settings.py
88+
db.sqlite3
89+
db.sqlite3-journal
90+
91+
# Flask stuff:
92+
instance/
93+
.webassets-cache
94+
95+
# Scrapy stuff:
96+
.scrapy
97+
98+
# Sphinx documentation
99+
docs/_build/
100+
101+
# PyBuilder
102+
target/
103+
104+
# Jupyter Notebook
105+
.ipynb_checkpoints
106+
107+
# IPython
108+
profile_default/
109+
ipython_config.py
110+
111+
# pyenv
112+
.python-version
113+
114+
# pipenv
115+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
116+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
117+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
118+
# install all needed dependencies.
119+
#Pipfile.lock
120+
121+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
122+
__pypackages__/
123+
124+
# Celery stuff
125+
celerybeat-schedule
126+
celerybeat.pid
127+
128+
# SageMath parsed files
129+
*.sage.py
130+
131+
# Environments
132+
.env
133+
.venv
134+
env/
135+
venv/
136+
ENV/
137+
env.bak/
138+
venv.bak/
139+
140+
# Spyder project settings
141+
.spyderproject
142+
.spyproject
143+
144+
# Rope project settings
145+
.ropeproject
146+
147+
# mkdocs documentation
148+
/site
149+
150+
# mypy
151+
.mypy_cache/
152+
.dmypy.json
153+
dmypy.json
154+
155+
# Pyre type checker
156+
.pyre/

README.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,39 @@
1-
# githubaction
2-
githubaction for AWS, GCP, CDK, Terraform
1+
# GitHub Actions
2+
3+
[![Build](https://github.com/DevSecOpsSamples/githubactions/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/DevSecOpsSamples/githubactions/actions/workflows/build.yml)
4+
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=DevSecOpsSamples_githubactions&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=DevSecOpsSamples_githubactions) [![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=DevSecOpsSamples_githubactions&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=DevSecOpsSamples_githubactions)
5+
6+
## Overview
7+
8+
Provides GitHub Workflow and Action samples.
9+
10+
## Sample Repositories
11+
12+
| Repository | Workflow File | Actions |
13+
|---|--------------------------------|------|
14+
| gke-workload-identity | [build.yml](https://github.com/DevSecOpsSamples/gke-workload-identity/blob/master/.github/workflows/build.yml) | [actions](https://github.com/DevSecOpsSamples/gke-workload-identity/actions/workflows/build.yml) | GCP, gcloud, Docker, Terraform, Python, pytest, Sonarqube |
15+
| jenkins-fargate-cdk | [build.yml](https://github.com/DevSecOpsSamples/jenkins-fargate-cdk/blob/master/.github/workflows/build.yml) | [actions](https://github.com/DevSecOpsSamples/jenkins-fargate-cdk/actions/workflows/build.yml) | Docker, CDK, Sonarqube |
16+
17+
## Docker
18+
19+
- Build multi-platform docker image files: [docker-buildx-gcr.yml](docker-buildx-gcr.yml)
20+
21+
## Cache
22+
23+
- Optimize build speed using the `cache` plugin: [java/README.md](java/README.md)
24+
25+
[java/.github/workflows/build-java.yml](java/.github/workflows/build-java.yml)
26+
27+
[java/.github/workflows/build-java-sonarqube.yml](java/.github/workflows/build-java-sonarqube.yml)
28+
29+
## Matrix
30+
31+
- [gke-workload-identity](https://github.com/DevSecOpsSamples/gke-workload-identity/blob/master/.github/workflows/build.yml)
32+
33+
## Reference
34+
35+
- [GitHub Actions /Using workflows / Cache dependencies / Caching dependencies to speed up workflows](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#managing-caches)
36+
37+
- https://github.com/actions/cache
38+
39+
- https://github.com/actions/cache/blob/main/examples.md#java---gradle

build-java-sonarqube.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Build & Sonarqube
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- develop
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
10+
jobs:
11+
gradle-sonarqube-cache:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Set up JDK 11
16+
uses: actions/setup-java@v1
17+
with:
18+
java-version: 11
19+
- name: Cache Gradle packages
20+
uses: actions/cache@v3
21+
with:
22+
path: |
23+
~/.gradle/caches
24+
~/.gradle/wrapper
25+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties') }}
26+
restore-keys: ${{ runner.os }}-gradle
27+
- name: Cache SonarCloud packages
28+
uses: actions/cache@v3
29+
with:
30+
path: ~/.sonar/cache
31+
key: ${{ runner.os }}-sonar
32+
restore-keys: ${{ runner.os }}-sonar
33+
- name: Build and analyze
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
37+
run: ./gradlew build sonarqube --info
38+
39+
gradle-sonarqube-no-cache:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v3
43+
- name: Set up JDK 11
44+
uses: actions/setup-java@v1
45+
with:
46+
java-version: 11
47+
- name: Build and analyze
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
51+
run: ./gradlew build sonarqube --info

build-java.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Build
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- develop
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
10+
jobs:
11+
gradle-cache:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Set up JDK 11
16+
uses: actions/setup-java@v1
17+
with:
18+
java-version: 11
19+
- name: Cache Gradle packages
20+
uses: actions/cache@v3
21+
with:
22+
path: |
23+
~/.gradle/caches
24+
~/.gradle/wrapper
25+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties') }}
26+
restore-keys: ${{ runner.os }}-gradle
27+
- name: Build and analyze
28+
run: ./gradlew build --info
29+
30+
gradle-no-cache:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v3
34+
- name: Set up JDK 11
35+
uses: actions/setup-java@v1
36+
with:
37+
java-version: 11
38+
- name: Build and analyze
39+
run: ./gradlew build --info
40+

build.gradle

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
plugins {
2+
id 'org.springframework.boot' version '2.2.1.RELEASE'
3+
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
4+
id 'java'
5+
id 'base'
6+
id "org.sonarqube" version "3.5.0.2730"
7+
}
8+
sourceCompatibility = '1.8'
9+
archivesBaseName = 'app'
10+
11+
repositories {
12+
mavenCentral()
13+
}
14+
15+
dependencies {
16+
implementation 'org.springframework.boot:spring-boot-starter-web'
17+
testImplementation('org.springframework.boot:spring-boot-starter-test') {
18+
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
19+
}
20+
}
21+
22+
springBoot {
23+
mainClassName = 'com.sample.SampleApplication.java'
24+
}
25+
test {
26+
useJUnitPlatform()
27+
}
28+
29+
sonarqube {
30+
properties {
31+
property "sonar.projectName", "githubactions"
32+
property "sonar.projectKey", "DevSecOpsSamples_githubactions"
33+
property "sonar.organization", "devsecopssamples"
34+
// property "sonar.host.url", "http://127.0.0.1:9000"
35+
property "sonar.host.url", "https://sonarcloud.io"
36+
property "sonar.sourceEncoding", "UTF-8"
37+
// property "sonar.java.binaries", "build"
38+
property "sonar.links.ci", "https://github.com/DevSecOpsSamples/githubactions/actions"
39+
}
40+
}

0 commit comments

Comments
 (0)