Skip to content

Commit

Permalink
chore: 🤖 update github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
polymath-eric committed Oct 11, 2024
1 parent 6f366c6 commit 2ae4300
Show file tree
Hide file tree
Showing 7 changed files with 261 additions and 33 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @PolymeshAssociation/middleware
48 changes: 48 additions & 0 deletions .github/workflows/authenticate-commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Authenticate Commits
on:
pull_request:
types: [opened, reopened, synchronize]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Import allowed SSH keys
env:
ALLOWED_SIGNERS: ${{ vars.MIDDLEWARE_ALLOWED_SIGNERS }}
run: |
mkdir -p ~/.ssh
echo "$ALLOWED_SIGNERS" > ~/.ssh/allowed_signers
git config --global gpg.ssh.allowedSignersFile "~/.ssh/allowed_signers"
- name: Validate commit signatures
env:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: |
# Function to verify a commit
verify_commit() {
local commit=$1
local status=$(git show --pretty="format:%G?" $commit | head -n 1)
if [ "$status" != "G" ]; then
local committer=$(git log -1 --pretty=format:'%cn (%ce)' $commit)
echo "Commit $commit from $committer has an invalid signature or is not signed by an allowed key."
exit 1
fi
}
# Get all commits in the PR
commits=$(git rev-list $BASE_SHA..$HEAD_SHA)
# Iterate over all commits in the PR and verify each one
for COMMIT in $commits; do
verify_commit $COMMIT
done
echo "All commits are signed with allowed keys."
27 changes: 27 additions & 0 deletions .github/workflows/fast-forward.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: fast-forward
on:
issue_comment:
types: [created, edited]
jobs:
fast-forward:
# Only run if the comment contains the /fast-forward command.
if: ${{ contains(github.event.comment.body, '/fast-forward')
&& github.event.issue.pull_request }}
runs-on: ubuntu-latest

permissions:
contents: write
pull-requests: write
issues: write

steps:
- name: Fast forwarding
uses: sequoia-pgp/fast-forward@v1
with:
merge: true
# To reduce the workflow's verbosity, use 'on-error'
# to only post a comment when an error occurs, or 'never' to
# never post a comment. (In all cases the information is
# still available in the step's summary.)
comment: on-error
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} ## This allows to trigger push action from within this workflow. Read more - https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow
17 changes: 9 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
env:
CI: true
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18.x'
cache: 'yarn'
Expand All @@ -29,8 +29,8 @@ jobs:
env:
CI: true
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18.x'
cache: 'yarn'
Expand All @@ -44,17 +44,18 @@ jobs:
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18.x'
node-version: '22.x'
cache: 'yarn'
- name: install dependencies
run: yarn --frozen-lockfile
- name: build
run: |
yarn build:ts
cp package.json dist/package.json
sed 's/dist\//.\//' package.json > dist/package.json
cp README.md dist/README.md
- name: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "typescript-repo-template",
"version": "0.0.0",
"description": "Template repository for typescript projects",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": "Polymesh Association",
"license": "ISC",
Expand All @@ -18,7 +17,9 @@
"devDependencies": {
"@commitlint/cli": "17.5.1",
"@commitlint/config-conventional": "17.4.4",
"@semantic-release/git": "10.0.1",
"@golevelup/ts-jest": "^0.5.6",
"@types/jest-when": "^3.5.5",
"@semantic-release/changelog": "^6.0.3",
"@types/jest": "27.4.0",
"@types/node": "18.15.11",
"@typescript-eslint/eslint-plugin": "5.57.0",
Expand All @@ -38,6 +39,7 @@
"eslint-plugin-standard": "5.0.0",
"husky": "8.0.3",
"jest": "29.5.0",
"jest-when": "^3.6.0",
"lint-staged": "13.2.0",
"prettier": "2.8.7",
"prettier-eslint": "15.0.1",
Expand Down
9 changes: 7 additions & 2 deletions release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@ module.exports = {
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
'@semantic-release/changelog',
[
'@semantic-release/npm',
{
tarballDir: 'npm-package/',
},
],
'@semantic-release/git',
'@semantic-release/github',
[
'@semantic-release/github',
{
assets: ['CHANGELOG.md'],
},
],
],
};
Loading

0 comments on commit 2ae4300

Please sign in to comment.