Skip to content

Commit aa659fa

Browse files
committed
fix: improve all workflows
1 parent f69cc6b commit aa659fa

9 files changed

Lines changed: 495 additions & 119 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
name: Bug Report
3+
description: Submit a bug report
4+
title: "[Bug]: "
5+
labels: ["bug", "triage"]
6+
# assignees:
7+
# - octocat
8+
body:
9+
- type: markdown
10+
attributes:
11+
value: |
12+
Thanks for taking the time to fill out this bug report!
13+
- type: input
14+
id: contact
15+
attributes:
16+
label: Contact Details
17+
description: How can we get in touch with you if we need more info?
18+
placeholder: ex. email@example.com
19+
validations:
20+
required: false
21+
- type: textarea
22+
id: what-happened
23+
attributes:
24+
label: What happened?
25+
description: Also tell us, what did you expect to happen?
26+
placeholder: Tell us what you see!
27+
value: "A bug happened!"
28+
validations:
29+
required: true
30+
- type: dropdown
31+
id: version
32+
attributes:
33+
label: Version
34+
description: What version of our software are you running?
35+
options:
36+
- 1.0.2 (Default)
37+
- 1.0.3 (Edge)
38+
validations:
39+
required: true
40+
- type: dropdown
41+
id: browsers
42+
attributes:
43+
label: What browsers are you seeing the problem on?
44+
multiple: true
45+
options:
46+
- Firefox
47+
- Chrome
48+
- Safari
49+
- Microsoft Edge
50+
- type: textarea
51+
id: logs
52+
attributes:
53+
label: Relevant log output
54+
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
55+
render: shell
56+
- type: checkboxes
57+
id: terms
58+
attributes:
59+
label: Code of Conduct
60+
description: By submitting this issue, you agree to follow our [Code of Conduct](https://example.com)
61+
options:
62+
- label: I agree to follow this project's Code of Conduct
63+
required: true

.github/workflows/delivery.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
2-
name: Continuous Delivery
2+
name: Delivery
33

44
on:
55
push:
66
branches: [main]
77

88
concurrency:
99
group: ${{ github.ref }}-${{ github.workflow }}
10-
cancel-in-progress: true
10+
cancel-in-progress: false
1111

1212
permissions:
1313
contents: write
@@ -21,4 +21,4 @@ jobs:
2121
release:
2222
uses: ./.github/workflows/semantic-release.yml
2323
secrets:
24-
token: ${{ secrets.GH_PAT }}
24+
GH_TOKEN: ${{ secrets.GH_PAT }}

.github/workflows/integration.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: Continuous Integration
2+
name: Integration
33

44
on:
55
pull_request:
@@ -28,23 +28,31 @@ jobs:
2828
uses: ./.github/workflows/semantic-pr.yml
2929

3030
lint:
31-
uses: ./.github/workflows/linter.yml
31+
uses: ./.github/workflows/mega-linter.yml@main
32+
secrets:
33+
GH_TOKEN: ${{ secrets.GH_PAT }}
3234

3335
# sonar:
3436
# uses: ./.github/workflows/sonar.yml
3537
# secrets:
36-
# token: ${{ env.SONAR_TOKEN }}
38+
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3739

3840
# terraform:
3941
# strategy:
42+
# # max-parallel: 1
43+
# fail-fast: false
4044
# matrix:
4145
# working-directory:
4246
# - 'terraform/deployments/dev'
4347
# - 'terraform/deployments/stage'
4448
# - 'terraform/deployments/prod'
4549
# uses: ./.github/workflows/terraform.yml
4650
# with:
51+
# state: cloud
4752
# version: 1.4.4
4853
# working-directory: ${{ matrix.working-directory }}
4954
# format: false
5055
# apply: false
56+
# secrets:
57+
# GH_TOKEN: ${{ secrets.GH_PAT }}
58+
# TF_API_TOKEN: ${{ secrets.TF_API_TOKEN }}

.github/workflows/linter.yml

Lines changed: 0 additions & 55 deletions
This file was deleted.

.github/workflows/mega-linter.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
---
2+
# MegaLinter GitHub Action configuration file
3+
# More info at https://megalinter.io
4+
# https://github.com/oxsecurity/megalinter
5+
# https://github.com/oxsecurity/megalinter/blob/main/TEMPLATES/mega-linter.yml
6+
name: MegaLinter
7+
8+
# Trigger mega-linter at every push. Action will also be visible from Pull Requests to main
9+
# Comment this line to trigger action only on pull-requests (not recommended if you don't pay for GH Actions)
10+
on:
11+
workflow_call:
12+
inputs:
13+
APPLY_FIXES_EVENT:
14+
description: |
15+
Apply MegaLinter fixes during given event: all, push, pull_request, none.
16+
type: string
17+
default: pull_request
18+
APPLY_FIXES_MODE:
19+
description: |
20+
`commit` to create a new commit and push it on the same branch, or
21+
`pull_request` to create a new PR targeting the branch.
22+
type: string
23+
default: pull_request
24+
VALIDATE_ALL_CODEBASE:
25+
description: |
26+
Validates all source when push on main, else just the git diff with main.
27+
Override with true if you always want to lint all sources.
28+
type: boolean
29+
default: false
30+
secrets:
31+
GH_TOKEN:
32+
required: true
33+
34+
env:
35+
APPLY_FIXES_EVENT: ${{ inputs.APPLY_FIXES_EVENT }}
36+
APPLY_FIXES_MODE: ${{ inputs.APPLY_FIXES_MODE }}
37+
VALIDATE_ALL_CODEBASE: ${{ inputs.VALIDATE_ALL_CODEBASE }}
38+
39+
jobs:
40+
lint:
41+
name: MegaLinter
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout Code
45+
uses: actions/checkout@v3
46+
with:
47+
token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
48+
fetch-depth: 0
49+
50+
- name: MegaLinter
51+
id: ml
52+
uses: oxsecurity/megalinter@v6
53+
env:
54+
VALIDATE_ALL_CODEBASE: ${{ inputs.VALIDATE_ALL_CODEBASE }}
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
57+
# Upload MegaLinter artifacts
58+
- name: Archive production artifacts
59+
if: ${{ success() }} || ${{ failure() }}
60+
uses: actions/upload-artifact@v3
61+
with:
62+
name: MegaLinter reports
63+
path: |
64+
megalinter-reports
65+
mega-linter.log
66+
67+
# Create pull request if applicable (for now works only on PR from same repository, not from forks)
68+
- name: Create Pull Request with applied fixes
69+
id: cpr
70+
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
71+
uses: peter-evans/create-pull-request@v5
72+
with:
73+
token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
74+
commit-message: "style(MegaLinter): apply linter fixes"
75+
title: "style(MegaLinter): apply linter fixes"
76+
labels: |
77+
state: pending
78+
type: chore
79+
work: obvious
80+
81+
- name: Create PR output
82+
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
83+
run: |
84+
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
85+
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
86+
87+
# Push new commit if applicable (for now works only on PR from same repository, not from forks)
88+
- name: Prepare commit
89+
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
90+
run: sudo chown -Rc $UID .git/
91+
92+
- name: Commit and push applied linter fixes
93+
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
94+
uses: stefanzweifel/git-auto-commit-action@v4
95+
with:
96+
branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }}
97+
commit_message: "style(MegaLinter): apply linter fixes"
98+
commit_user_name: informa-ap-devops
99+
commit_user_email: informa-ap-devops@users.noreply.github.com

.github/workflows/semantic-release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: Semantic Release
44
on:
55
workflow_call:
66
secrets:
7-
token:
7+
GH_TOKEN:
88
required: true
99

1010
permissions:
@@ -23,15 +23,15 @@ jobs:
2323
- name: Checkout
2424
uses: actions/checkout@v3
2525
with:
26-
token: ${{ secrets.token }}
26+
token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
2727
fetch-depth: 0
2828

2929
# https://github.com/marketplace/actions/semantic-release-action#usage
3030
- name: Semantic Release
3131
uses: docker://ghcr.io/codfish/semantic-release-action:v2
3232
id: semantic
3333
env:
34-
GITHUB_TOKEN: ${{ secrets.token }}
34+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
3535
with:
3636
tag_format: 'v${version}'
3737
additional_packages: |

.github/workflows/sonar.yml

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,22 @@ name: SonarSource, SonarCloud, SonarQube
77
on:
88
workflow_call:
99
inputs:
10-
cert:
11-
description: If SonarQube uses self-signed certificate, pass a root certificate (in PEM format)
10+
SONAR_HOST_URL:
11+
description: Specify the Sonar Host URL.
1212
type: string
13-
default: ''
14-
host:
15-
description: Specify SonarQube Host URL
16-
type: string
17-
default: ''
18-
gate:
19-
description: Use SonarQube Quality Gate in Status Checks?
13+
default: 'https://sonarcloud.io'
14+
SONAR_QUALITY_GATE_CHECK:
15+
description: Use Sonar Quality Gate in Status Checks?
2016
type: boolean
2117
default: false
22-
working-directory:
23-
description: Directory in which to run Sonar Scanner
18+
projectBaseDir:
19+
description: Directory in which to run Sonar Scanner.
2420
type: string
25-
default: ./
21+
default: ${{ $GITHUB_WORKSPACE }}
2622
secrets:
27-
token:
23+
# If SonarQube uses self-signed certificate, pass a root certificate (in PEM format).
24+
SONAR_ROOT_CERT: ''
25+
SONAR_TOKEN:
2826
required: true
2927

3028
permissions:
@@ -43,40 +41,40 @@ jobs:
4341
fetch-depth: 0
4442

4543
- name: SonarCloud Scan
46-
if: ${{ inputs.host == '' }}
44+
if: ${{ inputs.SONAR_HOST_URL == '' }}
4745
uses: SonarSource/sonarcloud-github-action@master
4846
with:
49-
projectBaseDir: ${{ inputs.working-directory }}
47+
projectBaseDir: ${{ inputs.projectBaseDir }}
5048
env:
5149
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5250
# SonarCloud access token should be generated from https://sonarcloud.io/account/security/
53-
SONAR_TOKEN: ${{ secrets.token }}
51+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
5452

5553
- name: SonarQube Scan
56-
if: ${{ inputs.host != '' }}
54+
if: ${{ inputs.SONAR_HOST_URL != '' }}
5755
uses: sonarsource/sonarqube-scan-action@master
5856
with:
59-
projectBaseDir: ${{ inputs.working-directory }}
57+
projectBaseDir: ${{ inputs.projectBaseDir }}
6058
env:
6159
# SonarQube access token should be generated from https://sonarcloud.io/account/security/
62-
SONAR_TOKEN: ${{ secrets.token }}
63-
SONAR_HOST_URL: ${{ inputs.host }}
64-
# SONAR_ROOT_CERT: ${{ inputs.cert }}
60+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
61+
SONAR_HOST_URL: ${{ inputs.SONAR_HOST_URL }}
62+
# SONAR_ROOT_CERT: ${{ secrets.SONAR_ROOT_CERT }}
6563

6664
# Check the Quality Gate status.
6765
- name: SonarQube Quality Gate check
6866
id: sonarqube-quality-gate-check
69-
if: ${{ inputs.host != '' && inputs.gate == true }}
67+
if: ${{ inputs.SONAR_HOST_URL != '' && inputs.SONAR_QUALITY_GATE_CHECK == true }}
7068
uses: sonarsource/sonarqube-quality-gate-action@master
7169
# Force to fail step after specific time.
7270
timeout-minutes: 5
7371
env:
74-
SONAR_TOKEN: ${{ secrets.token }}
75-
SONAR_HOST_URL: ${{ inputs.host }}
76-
# SONAR_ROOT_CERT: ${{ inputs.cert }}
72+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
73+
SONAR_HOST_URL: ${{ inputs.SONAR_HOST_URL }}
74+
# SONAR_ROOT_CERT: ${{ secrets.SONAR_ROOT_CERT }}
7775

7876
# Optionally you can use the output from the Quality Gate in another step.
7977
# The possible outputs of the `quality-gate-status` variable are `PASSED`, `WARN` or `FAILED`.
8078
- name: SonarQube Quality Gate Status
81-
if: ${{ inputs.host != '' && inputs.gate == true }}
79+
if: ${{ inputs.SONAR_HOST_URL != '' && inputs.SONAR_QUALITY_GATE_CHECK == true }}
8280
run: echo "The Quality Gate status is ${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }}"

0 commit comments

Comments
 (0)