Skip to content

Commit 955f7b0

Browse files
authoredJan 28, 2025··
Move external actions and workflows locally (#1919)
* move actions and workflows locally * move shared workflows
1 parent 65b28a9 commit 955f7b0

File tree

7 files changed

+241
-9
lines changed

7 files changed

+241
-9
lines changed
 

‎.changeset/smooth-poets-rush.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphprotocol/graph-cli': patch
3+
---
4+
5+
chore: move github actions around

‎.github/actions/setup-node/action.yml

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Note: This is a composite GitHub Actions, it should do all env setup, caching an so on, so other pipelines can just compose their own stuff on top of that.
2+
# Docs: https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
3+
4+
name: Configure Environment
5+
description: Shared configuration for checkout, Node.js and package manager
6+
inputs:
7+
nodeVersion:
8+
description: Node.js version to use
9+
required: true
10+
default: '20'
11+
workingDirectory:
12+
description: Working directory
13+
required: false
14+
default: ./
15+
packageManager:
16+
description: Package manager
17+
required: false
18+
default: yarn
19+
packageManagerVersion:
20+
description: Package manager version
21+
required: false
22+
default: ''
23+
24+
runs:
25+
using: composite
26+
steps:
27+
- name: Cancel Previous Runs
28+
uses: styfle/cancel-workflow-action@0.12.1
29+
continue-on-error: true
30+
with:
31+
access_token: ${{ github.token }}
32+
33+
- name: check pnpm version
34+
shell: bash
35+
id: pnpm
36+
if: inputs.packageManager == 'pnpm'
37+
working-directory: ${{ inputs.workingDirectory }}
38+
run: |
39+
PNPM_VERSION=${PNPM_VERSION:-9.0.6}
40+
PKG_JSON=$(cat package.json | jq -r '.packageManager' | awk -F@ '{print $2}')
41+
if [ ! -z $PKG_JSON ]; then
42+
PNPM_VERSION=$PKG_JSON
43+
fi
44+
if [ ! -z {{inputs.packageManager}} ]; then
45+
PNPM_VERSION=${{ inputs.packageManagerVersion }}
46+
fi
47+
echo "Using PNPM version $PNPM_VERSION"
48+
echo "version=$PNPM_VERSION" >> $GITHUB_OUTPUT
49+
50+
- name: Setup ${{ inputs.packageManager }}
51+
id: pnpm_setup
52+
if: inputs.packageManager == 'pnpm'
53+
uses: pnpm/action-setup@v4.0.0
54+
with:
55+
version: ${{ steps.pnpm.outputs.version }}
56+
run_install: false
57+
package_json_file: ${{ inputs.workingDirectory }}/package.json
58+
59+
- name: setup node
60+
uses: actions/setup-node@v4
61+
with:
62+
node-version: ${{ inputs.nodeVersion }}
63+
cache: ${{ inputs.packageManager }}
64+
cache-dependency-path: |
65+
**/pnpm-lock.yaml
66+
**/yarn.lock
67+
patches/**
68+
69+
- name: yarn install
70+
shell: bash
71+
if: inputs.packageManager == 'yarn' && inputs.packageManagerVersion == ''
72+
run: yarn install --ignore-engines --frozen-lockfile --immutable
73+
working-directory: ${{ inputs.workingDirectory }}
74+
75+
- name: modern yarn install
76+
shell: bash
77+
if: inputs.packageManager == 'yarn' && inputs.packageManagerVersion == 'modern'
78+
run: corepack enable && yarn
79+
working-directory: ${{ inputs.workingDirectory }}
80+
81+
- name: pnpm install
82+
shell: bash
83+
if: inputs.packageManager == 'pnpm'
84+
run: pnpm install --frozen-lockfile
85+
working-directory: ${{ inputs.workingDirectory }}

‎.github/workflows/ci.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Checkout Repository
1616
uses: actions/checkout@v4
1717

18-
- uses: the-guild-org/shared-config/setup@main
18+
- uses: ./.github/actions/setup-node
1919
name: Setup Env
2020
with:
2121
nodeVersion: 20
@@ -37,7 +37,7 @@ jobs:
3737
- name: Checkout Repository
3838
uses: actions/checkout@v4
3939

40-
- uses: the-guild-org/shared-config/setup@main
40+
- uses: ./.github/actions/setup-node
4141
name: Setup Env
4242
with:
4343
nodeVersion: ${{ matrix.node-version }}
@@ -67,7 +67,7 @@ jobs:
6767
- name: Checkout Repository
6868
uses: actions/checkout@v4
6969

70-
- uses: the-guild-org/shared-config/setup@main
70+
- uses: ./.github/actions/setup-node
7171
name: Setup Env
7272
with:
7373
nodeVersion: 20
@@ -95,7 +95,7 @@ jobs:
9595
- name: Checkout Repository
9696
uses: actions/checkout@v4
9797

98-
- uses: the-guild-org/shared-config/setup@main
98+
- uses: ./.github/actions/setup-node
9999
name: Setup Env
100100
with:
101101
nodeVersion: 20

‎.github/workflows/pr.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ permissions: write-all
88

99
jobs:
1010
dependencies:
11-
uses: the-guild-org/shared-config/.github/workflows/changesets-dependencies.yaml@main
11+
uses: ./.github/workflows/shared-changesets-dependencies.yml
1212
if: ${{ github.event.pull_request.title != 'Upcoming Release Changes' }}
1313
secrets:
1414
githubToken: ${{ secrets.GITHUB_TOKEN }}
1515

1616
alpha:
17-
uses: the-guild-org/shared-config/.github/workflows/release-snapshot.yml@main
17+
uses: ./.github/workflows/shared-release-snapshot.yml
1818
if: ${{ github.event.pull_request.title != 'Upcoming Release Changes' }}
1919
with:
2020
npmTag: alpha
@@ -27,7 +27,7 @@ jobs:
2727
npmToken: ${{ secrets.NPM_TOKEN }}
2828

2929
release-candidate:
30-
uses: the-guild-org/shared-config/.github/workflows/release-snapshot.yml@main
30+
uses: ./.github/workflows/shared-release-snapshot.yml
3131
if: ${{ github.event.pull_request.title == 'Upcoming Release Changes' }}
3232
with:
3333
npmTag: rc

‎.github/workflows/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
fetch-depth: 0
2121
token: ${{ secrets.GITHUB_TOKEN }}
2222
- name: Setup environment
23-
uses: the-guild-org/shared-config/setup@main
23+
uses: ./.github/actions/setup-node
2424
with:
2525
nodeVersion: 20
2626
packageManager: pnpm
@@ -38,7 +38,7 @@ jobs:
3838
if: ${{ startsWith(github.event.head_commit.message, env.RELEASE_COMMIT_MSG) }}
3939
run: pnpm --filter=@graphprotocol/graph-cli oclif:pack
4040
- name: Release / pull_request
41-
uses: dotansimha/changesets-action@v1.5.0
41+
uses: pinax-network/changesets-release-action@v1.5.2
4242
with:
4343
publish: pnpm release
4444
version: pnpm changeset version
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Note: this is a shared pipeline used by other repositories.
2+
# Docs: https://docs.github.com/en/actions/using-workflows/reusing-workflows
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
installDependencies:
8+
type: boolean
9+
default: false
10+
preCommit:
11+
type: string
12+
required: false
13+
packageManager:
14+
type: string
15+
required: false
16+
default: yarn
17+
packageManagerVersion:
18+
type: string
19+
description: Package manager version
20+
required: false
21+
default: ''
22+
nodeVersion:
23+
required: false
24+
type: string
25+
default: '20'
26+
secrets:
27+
githubToken:
28+
required: true
29+
30+
jobs:
31+
changeset:
32+
runs-on: ubuntu-24.04
33+
if: github.event.pull_request.head.repo.full_name == github.repository
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
with:
38+
fetch-depth: 0
39+
token: ${{ secrets.githubToken }}
40+
41+
- uses: ./.github/actions/setup-node
42+
name: setup env and install dependencies
43+
if: ${{ inputs.installDependencies }}
44+
with:
45+
nodeVersion: ${{ inputs.nodeVersion }}
46+
packageManager: ${{ inputs.packageManager }}
47+
packageManagerVersion: ${{ inputs.packageManagerVersion }}
48+
49+
- name: Create/Update Changesets
50+
uses: pinax-network/changesets-dependencies-action@v1.2.2
51+
with:
52+
preCommit: ${{ inputs.preCommit }}
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.githubToken }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Note: this is a shared pipeline used by other repositories.
2+
# Docs: https://docs.github.com/en/actions/using-workflows/reusing-workflows
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
packageManager:
8+
type: string
9+
required: false
10+
default: yarn
11+
packageManagerVersion:
12+
description: Package manager version
13+
type: string
14+
required: false
15+
default: ''
16+
nodeVersion:
17+
required: false
18+
type: string
19+
default: '20'
20+
buildScript:
21+
required: false
22+
type: string
23+
default: build
24+
npmTag:
25+
required: false
26+
type: string
27+
default: npmTag
28+
exitPre:
29+
required: false
30+
type: boolean
31+
default: false
32+
restoreDeletedChangesets:
33+
required: false
34+
type: boolean
35+
default: false
36+
secrets:
37+
githubToken:
38+
required: true
39+
npmToken:
40+
required: true
41+
outputs:
42+
published:
43+
description: A boolean value to indicate whether a publishing is happened or not
44+
value: ${{ jobs.snapshot.outputs.published }}
45+
publishedPackages:
46+
description:
47+
'A JSON array to present the published packages. The format is [{"name": "@xx/xx",
48+
"version": "1.2.0"}, {"name": "@xx/xy", "version": "0.8.9"}]'
49+
value: ${{ jobs.snapshot.outputs.publishedPackages }}
50+
51+
jobs:
52+
snapshot:
53+
runs-on: ubuntu-24.04
54+
if: github.event.pull_request.head.repo.full_name == github.repository
55+
outputs:
56+
published: ${{ steps.changesets.outputs.published }}
57+
publishedPackages: ${{ steps.changesets.outputs.publishedPackages }}
58+
steps:
59+
- name: checkout
60+
uses: actions/checkout@v4
61+
with:
62+
fetch-depth: 0
63+
ref: ${{ github.event.pull_request.head.sha }}
64+
65+
- uses: ./.github/actions/setup-node
66+
name: setup env
67+
with:
68+
nodeVersion: ${{inputs.nodeVersion}}
69+
packageManager: ${{inputs.packageManager}}
70+
packageManagerVersion: ${{inputs.packageManagerVersion}}
71+
72+
- if: inputs.exitPre
73+
name: Exit Prerelease Mode
74+
run: ${{inputs.packageManager}} run changeset pre exit
75+
76+
- if: inputs.restoreDeletedChangesets
77+
name: restore deleted changesets
78+
run: git checkout HEAD~1 -- .
79+
80+
- name: ${{ inputs.npmTag }} release
81+
id: changesets
82+
uses: pinax-network/changesets-snapshot-action@v0.0.3
83+
with:
84+
tag: ${{ inputs.npmTag }}
85+
prepareScript: '${{inputs.packageManager}} run ${{ inputs.buildScript }}'
86+
env:
87+
NPM_TOKEN: ${{ secrets.npmToken }}
88+
GITHUB_TOKEN: ${{ secrets.githubToken }}

0 commit comments

Comments
 (0)
Please sign in to comment.