-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a Shared Workflow for Release Please (#8)
* style: format shared workflows * feat(workflows): add release-please shared action * fix(workflows): make release-please triggered by workflow_call
- Loading branch information
1 parent
c99b2ff
commit 45ebb7f
Showing
4 changed files
with
136 additions
and
115 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,43 @@ | ||
name: Assign issues and PRs to project | ||
|
||
on: | ||
issues: | ||
types: [opened, reopened] | ||
issues: | ||
types: [opened, reopened] | ||
|
||
pull_request: | ||
types: [opened, reopened] | ||
pull_request: | ||
types: [opened, reopened] | ||
|
||
workflow_call: | ||
inputs: | ||
project-id: | ||
default: 2 | ||
description: Issues and PRs will be assigned to that project. Default to 2 (Hedia). | ||
required: false | ||
type: number | ||
workflow_call: | ||
inputs: | ||
project-id: | ||
default: 2 | ||
description: Issues and PRs will be assigned to that project. Default to 2 (Hedia). | ||
required: false | ||
type: number | ||
|
||
secrets: | ||
ASSIGN_TO_PROJECT_TOKEN: | ||
description: Personal Access Token with "repo" and "project" permissions. | ||
required: true | ||
secrets: | ||
ASSIGN_TO_PROJECT_TOKEN: | ||
description: Personal Access Token with "repo" and "project" permissions. | ||
required: true | ||
|
||
jobs: | ||
project: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 1 | ||
steps: | ||
project: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 1 | ||
steps: | ||
- id: addItem | ||
name: Add to project | ||
uses: actions/[email protected] | ||
with: | ||
project-url: https://github.com/orgs/hedia-team/projects/${{inputs.project-id || 2}} | ||
github-token: ${{ secrets.ASSIGN_TO_PROJECT_TOKEN }} | ||
|
||
- id: addItem | ||
name: Add to project | ||
uses: actions/[email protected] | ||
with: | ||
project-url: https://github.com/orgs/hedia-team/projects/${{inputs.project-id || 2}} | ||
github-token: ${{ secrets.ASSIGN_TO_PROJECT_TOKEN }} | ||
|
||
- if: github.event_name == 'pull_request' | ||
name: Set status | ||
uses: hedia-team/[email protected] | ||
with: | ||
project-url: https://github.com/orgs/hedia-team/projects/${{inputs.project-id || 2}} | ||
github-token: ${{ secrets.ASSIGN_TO_PROJECT_TOKEN }} | ||
item-id: ${{ steps.addItem.outputs.itemId }} | ||
field-keys: Status | ||
field-values: In Progress | ||
- if: github.event_name == 'pull_request' | ||
name: Set status | ||
uses: hedia-team/[email protected] | ||
with: | ||
project-url: https://github.com/orgs/hedia-team/projects/${{inputs.project-id || 2}} | ||
github-token: ${{ secrets.ASSIGN_TO_PROJECT_TOKEN }} | ||
item-id: ${{ steps.addItem.outputs.itemId }} | ||
field-keys: Status | ||
field-values: In Progress |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,94 @@ | ||
name: Run Build, Tests & SonarCloud Scan | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
database: | ||
description: Database used in this workflow. Default to none | ||
required: false | ||
type: string | ||
workflow_call: | ||
inputs: | ||
database: | ||
description: Database used in this workflow. Default to none | ||
required: false | ||
type: string | ||
|
||
secrets: | ||
READONLY_NPM_TOKEN: | ||
description: Needed to install private @hedia npm packages | ||
required: true | ||
SONAR_TOKEN: | ||
description: Needed to run SonarCloud Scan | ||
required: true | ||
BREVO_API_KEY: | ||
description: Token needed to authenticate requests to Brevo API if any | ||
required: false | ||
PRIVATE_KEY: | ||
description: Private JSON Web Key that might be needed to run test script | ||
required: false | ||
PUBLIC_KEY: | ||
description: Public JSON Web Key that might be needed to run test script | ||
required: false | ||
secrets: | ||
READONLY_NPM_TOKEN: | ||
description: Needed to install private @hedia npm packages | ||
required: true | ||
SONAR_TOKEN: | ||
description: Needed to run SonarCloud Scan | ||
required: true | ||
BREVO_API_KEY: | ||
description: Token needed to authenticate requests to Brevo API if any | ||
required: false | ||
PRIVATE_KEY: | ||
description: Private JSON Web Key that might be needed to run test script | ||
required: false | ||
PUBLIC_KEY: | ||
description: Public JSON Web Key that might be needed to run test script | ||
required: false | ||
|
||
jobs: | ||
build-test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
build-test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
|
||
services: | ||
postgres: | ||
image: ${{ inputs.database && 'postgres' || '' }} | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: password | ||
POSTGRES_DB: ${{ inputs.database }} | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
- 5432:5432 | ||
services: | ||
postgres: | ||
image: ${{ inputs.database && 'postgres' || '' }} | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: password | ||
POSTGRES_DB: ${{ inputs.database }} | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
- 5432:5432 | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of SonarCloud analysis | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of SonarCloud analysis | ||
|
||
- name: Setup Node.js Environment | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: "package.json" | ||
always-auth: true | ||
registry-url: https://registry.npmjs.org | ||
scope: "@hedia" | ||
- name: Setup Node.js Environment | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: "package.json" | ||
always-auth: true | ||
registry-url: https://registry.npmjs.org | ||
scope: "@hedia" | ||
|
||
- name: "Install Dependencies" | ||
run: npm ci | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.READONLY_NPM_TOKEN }} | ||
- name: "Install Dependencies" | ||
run: npm ci | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.READONLY_NPM_TOKEN }} | ||
|
||
- name: "Build Repository" | ||
run: "npm run build --if-present" | ||
- name: "Build Repository" | ||
run: "npm run build --if-present" | ||
|
||
- name: "Setup Service" | ||
run: "NODE_ENV=test npm run setup --if-present" | ||
- name: "Setup Service" | ||
run: "NODE_ENV=test npm run setup --if-present" | ||
|
||
- name: "Run Tests" | ||
run: "npm run test" | ||
env: | ||
BREVO_API_KEY: ${{ secrets.BREVO_API_KEY }} | ||
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} | ||
PUBLIC_KEY: ${{ secrets.PUBLIC_KEY }} | ||
- name: "Run Tests" | ||
run: "npm run test" | ||
env: | ||
BREVO_API_KEY: ${{ secrets.BREVO_API_KEY }} | ||
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} | ||
PUBLIC_KEY: ${{ secrets.PUBLIC_KEY }} | ||
|
||
- name: SonarCloud Init | ||
env: | ||
GITHUB_PROJECT: ${{ github.repository }} | ||
run: echo "GITHUB_PROJECT=${GITHUB_PROJECT/\//_}" >> $GITHUB_ENV | ||
- name: SonarCloud Init | ||
env: | ||
GITHUB_PROJECT: ${{ github.repository }} | ||
run: echo "GITHUB_PROJECT=${GITHUB_PROJECT/\//_}" >> $GITHUB_ENV | ||
|
||
- name: SonarCloud Scan | ||
uses: SonarSource/sonarcloud-github-action@master | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
with: | ||
args: > | ||
-Dsonar.projectKey=${{ env.GITHUB_PROJECT }} | ||
-Dsonar.organization=${{ github.repository_owner }} | ||
-Dsonar.coverageReportPaths=coverage.xml | ||
- name: SonarCloud Scan | ||
uses: SonarSource/sonarcloud-github-action@master | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
with: | ||
args: > | ||
-Dsonar.projectKey=${{ env.GITHUB_PROJECT }} | ||
-Dsonar.organization=${{ github.repository_owner }} | ||
-Dsonar.coverageReportPaths=coverage.xml |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Release Please | ||
|
||
on: | ||
workflow_call: | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
release-please: | ||
runs-on: ubuntu-latest | ||
if: > | ||
github.event_name == 'workflow_dispatch' || | ||
(github.event_name == 'pull_request' && | ||
github.event.pull_request.merged == true && | ||
contains(github.event.pull_request.labels.*.name, 'autorelease: pending') | ||
) | ||
steps: | ||
- uses: google-github-actions/release-please-action@v3 | ||
with: | ||
release-type: node |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
# .github | ||
# .github |