Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(github-actions): enable various imperative github actions #847

Merged
merged 7 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ on:
env:
PRODUCT: apim
ENVIRONMENT: ${{ github.ref_name }}
TIMEZONE: "Europe/London"
timezone: ${{ vars.TIMEZONE }}
oscar-richardson-softwire marked this conversation as resolved.
Show resolved Hide resolved
# Base artifact
FROM: latest

Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/github.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: GitHub
oscar-richardson-softwire marked this conversation as resolved.
Show resolved Hide resolved
run-name: 🔬Pull request inspection on ${{ github.event.number }}
oscar-richardson-softwire marked this conversation as resolved.
Show resolved Hide resolved

on:
pull_request:
branches:
- main
- "release-*"

env:
environment: dev
timezone: ${{ vars.TIMEZONE }}

jobs:
# 1. Setup test infrastructure
setup:
name: Infrastructure setup 🔧
runs-on: ubuntu-latest
outputs:
environment: ${{ env.environment }}
timezone: ${{ env.timezone }}
steps:
- name: Environment 🧪
run: echo "Environment set to ${{ env.environment }}"

- name: Timezone 🌐
run: echo "Timezone set to ${{ env.timezone }}"

# 2. Pull request
pullrequest:
name: Pull request ⬇️
oscar-richardson-softwire marked this conversation as resolved.
Show resolved Hide resolved
environment:
name: ${{ needs.setup.outputs.environment }}
runs-on: ubuntu-latest
steps:
- name: Timezone
uses: szenius/set-timezone@v1.2
with:
timezoneLinux: ${{ needs.setup.outputs.timezone }}

- name: Repository
uses: actions/checkout@v4

- name: Node
uses: actions/setup-node@v3
with:
node-version: ${{ vars.NODE_VERSION }}

- name: Dependencies
working-directory: ./
run: npm ci --legacy-peer-deps

- name: Title
run: echo "${{ github.event.pull_request.title }}" | npx commitlint --color --verbose $1

- name: Body
if: ${{ github.event.pull_request.body == '' }}
run: exit 1

- name: Label
if: ${{ github.event.pull_request.labels == '[]' }}
run: exit 1

- name: Assignee
if: ${{ github.event.pull_request.assignee == '[]' }}
run: exit 1
2 changes: 1 addition & 1 deletion .github/workflows/infrastructure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ on:
env:
PRODUCT: apim
ENVIRONMENT: infrastructure
TIMEZONE: "Europe/London"
timezone: ${{ vars.TIMEZONE }}
oscar-richardson-softwire marked this conversation as resolved.
Show resolved Hide resolved
# Deployment environment target i.e., `dev`, `staging`, `production`
TARGET: ${{ vars.ENVIRONMENT }}

Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ on:

env:
environment: "qa"
timezone: "Europe/London"
node: ${{ vars.NODE_VERSION }}
timezone: ${{ vars.TIMEZONE }}

jobs:
# 1. Setup test infrastructure
Expand Down Expand Up @@ -50,7 +49,7 @@ jobs:
- name: Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.node }}
node-version: ${{ vars.NODE_VERSION }}

- name: Dependencies
working-directory: ./
Expand All @@ -59,3 +58,7 @@ jobs:
- name: Linting
working-directory: ./
run: npm run lint

- name: Prettier
working-directory: ./
run: npm run prettier
53 changes: 53 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This YAML configuration defines a GitHub Actions workflow named "PR" designed to analyse pull requests
# for staleness and take action accordingly.
#
# Identify: Uses the actions/stale@v5 action with parameters to mark pull requests as stale if
# they have been inactive for a certain number of days and close them if they exceed another threshold.
# This workflow helps maintain the health of the pull request queue by identifying and managing stale pull requests automatically.
#

name: PR
run-name: 🔎 pull request analysis on ${{ github.event.number }}
oscar-richardson-softwire marked this conversation as resolved.
Show resolved Hide resolved

on:
schedule:
- cron: "00 00 * * *"
env:
environment: dev
timezone: ${{ vars.TIMEZONE }}

jobs:
# 1. Setup test infrastructure
setup:
name: Infrastructure setup 🔧
runs-on: ubuntu-latest
outputs:
environment: ${{ env.environment }}
timezone: ${{ env.timezone }}
steps:
- name: Environment 🧪
run: echo "Environment set to ${{ env.environment }}"

- name: Timezone 🌐
run: echo "Timezone set to ${{ env.timezone }}"

# 2. Identify stale PRs
stale:
name: Stale 📅
needs: setup
environment:
name: ${{ needs.setup.outputs.environment }}
runs-on: ubuntu-latest
permissions:
pull-requests: write

steps:
- name: Identify
uses: actions/stale@v9
with:
days-before-pr-stale: ${{ vars.STALE_PR_DAYS }}
stale-pr-message: "Pull request marked as stale due to inactivity."
stale-pr-label: "Stale"
days-before-pr-close: ${{ vars.CLOSE_PR_DAYS }}
close-pr-message: "Pull request has been closed due to inactivity."
close-pr-label: "Closed"
46 changes: 37 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# MDM-API Git Hub Actions
# MDM Git Hub Actions
#####################################
# This GHA is responsible for release version updates.
# This GHA is responsible for creating automated
# GitHub release based PR. Once the PR is merged
# Google release please will update the `CHANGELOG.md`
# `README.md` and `package.json` files.
# Followed by tagging the commit with the appropriate version
# number (as per SemVer) and create a GitHub release on the tag.

oscar-richardson-softwire marked this conversation as resolved.
Show resolved Hide resolved
name: Automated release
run-name: Executing release on ${{ github.repository }} 🚀
Expand All @@ -14,13 +19,36 @@ permissions:
pull-requests: write

jobs:
# 1. `package.json`, `README.md` and `CHANGELOG.md` updates
# 1. Setup test infrastructure
setup:
name: Infrastructure setup 🔧
runs-on: ubuntu-latest
outputs:
environment: ${{ env.environment }}
timezone: ${{ env.timezone }}
steps:
- name: Environment 🧪
run: echo "Environment set to ${{ env.environment }}"

- name: Timezone 🌐
run: echo "Timezone set to ${{ env.timezone }}"

# 2. Update files
release:
name: Release setup 🔧
name: Release ✨
needs: setup
environment:
name: ${{ needs.setup.outputs.environment }}
runs-on: ubuntu-latest

steps:
- name: Release version ⚡️
uses: google-github-actions/release-please-action@v4
with:
token: ${{ secrets.RELEASE_TOKEN }}
release-type: node
- name: Repository
uses: actions/checkout@v4

- name: Dependency
working-directory: ./
run: npm i -g release-please

- name: Create
working-directory: ./
run: npx release-please release-pr --token=${{ secrets.RELEASE_TOKEN }} --repo-url=https://github.com/${{ github.repository }} --release-type=node
2 changes: 1 addition & 1 deletion .github/workflows/sca.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:

env:
environment: "qa"
timezone: "Europe/London"
timezone: ${{ vars.TIMEZONE }}

jobs:
# 1. Setup test infrastructure
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ on:

env:
environment: "qa"
timezone: "Europe/London"
node: ${{ vars.NODE_VERSION }}
oscar-richardson-softwire marked this conversation as resolved.
Show resolved Hide resolved
timezone: ${{ vars.TIMEZONE }}

jobs:
# 1. Setup test infrastructure
Expand Down Expand Up @@ -53,7 +52,7 @@ jobs:
- name: Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.node }}
node-version: ${{ vars.NODE_VERSION }}

- name: Dependencies
working-directory: ./
Expand Down
3 changes: 1 addition & 2 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx commitlint --edit $1
npx lint-staged
npx commitlint --color --edit $1
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"postinstall": "husky install",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"prettier": "prettier --no-error-on-unmatched-pattern --check **/*.{ts,js}",
"spellcheck": "cspell lint --gitignore --no-must-find-files --unique --no-progress --show-suggestions --color '**/*'",
"start": "nest start",
"start:debug": "nest start --debug --watch",
Expand All @@ -21,8 +22,10 @@
},
"lint-staged": {
"**/package.json": "sort-package-json",
"**/*.js": "eslint --fix",
"**/*.ts": "eslint --fix",
"**/*.{js,ts}": [
"eslint --fix",
"prettier --write"
],
"**/*": [
"cspell lint --gitignore --no-must-find-files --unique --no-progress --show-suggestions --color"
]
Expand Down
Loading