Skip to content

Commit c7c9fb2

Browse files
authored
chore: migrate to gha publishing [DX-535] (#3160)
* feat: gha test workflow * chore: workflow files added * fix: correct branch name in script * test: e2e access * test: integration:ci job * test: integration:ci job * test: circleci config removed * chore: vault secret updated * fix: node version update in check.yml * fix: jest config update * chore: test changes reverted * fix: release job updated * fix: workflow dependencies updated * chore: package update * test * test * test * fix: sem version update * chore: package lock * fix: e2e parallelism denied * test: test e2e cleanup * feat: ready for merge * chore: pull request trigger removed * chore: codeql name change
1 parent 0660b46 commit c7c9fb2

File tree

13 files changed

+2044
-1866
lines changed

13 files changed

+2044
-1866
lines changed

.circleci/config.yml

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

.contentful/vault-secrets.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@ services:
55
- dependabot
66
- semantic-release
77
- packages-read
8-
circleci:
9-
policies:
10-
- semantic-release-ecosystem

.github/workflows/build.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
10+
permissions:
11+
contents: read
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v5
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v6
19+
with:
20+
node-version: "22"
21+
cache: "npm"
22+
23+
- name: Install dependencies
24+
run: npm ci
25+
26+
- name: Build
27+
run: npm run build:package
28+
29+
- name: Check build artifacts
30+
run: ls -la dist/
31+
32+
- name: Save Build folders
33+
uses: actions/cache/save@v4
34+
with:
35+
path: |
36+
dist
37+
build
38+
key: build-cache-${{ github.run_id }}-${{ github.run_attempt }}

.github/workflows/check.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Run Checks
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
VAULT_URL:
7+
required: true
8+
CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN:
9+
required: true
10+
CLI_E2E_ORG_ID:
11+
required: true
12+
13+
jobs:
14+
check:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v5
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v6
23+
with:
24+
node-version: "22"
25+
cache: "npm"
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Restore the build folders
31+
uses: actions/cache/restore@v4
32+
with:
33+
path: |
34+
dist
35+
build
36+
key: build-cache-${{ github.run_id }}-${{ github.run_attempt }}
37+
38+
# Prior ci publishing did not lint or format, commented out to preserve workflow
39+
# - name: Run linter
40+
# run: npm run lint
41+
42+
#- name: Check formatting
43+
# run: npm run prettier:check
44+
# env:
45+
# CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN: ${{ secrets.CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN }}
46+
# CLI_E2E_ORG_ID: ${{ secrets.CLI_E2E_ORG_ID }}
47+
48+
- name: Run unit tests
49+
run: npm test
50+
env:
51+
CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN: ${{ secrets.CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN }}
52+
CLI_E2E_ORG_ID: ${{ secrets.CLI_E2E_ORG_ID }}
53+
54+
- name: Run integration tests
55+
run: npm run test:integration:ci
56+
env:
57+
CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN: ${{ secrets.CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN }}
58+
CLI_E2E_ORG_ID: ${{ secrets.CLI_E2E_ORG_ID }}

.github/workflows/codeql.yml renamed to .github/workflows/codeql.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ on:
55
push:
66
branches: [main]
77
paths: [".github/workflows/**"]
8-
pull_request:
9-
branches: [main]
10-
paths: [".github/workflows/**"]
118

129
jobs:
1310
analyze:
@@ -19,14 +16,14 @@ jobs:
1916
security-events: write
2017

2118
steps:
22-
- uses: actions/checkout@v4
19+
- uses: actions/checkout@v5
2320

2421
- name: Initialize CodeQL
25-
uses: github/codeql-action/init@v3
22+
uses: github/codeql-action/init@v4
2623
with:
2724
languages: actions
2825

2926
- name: Run CodeQL Analysis
30-
uses: github/codeql-action/analyze@v3
27+
uses: github/codeql-action/analyze@v4
3128
with:
3229
category: actions

.github/workflows/main.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
permissions:
3+
contents: read
4+
5+
on:
6+
push:
7+
branches: ["*"]
8+
9+
jobs:
10+
build:
11+
uses: ./.github/workflows/build.yaml
12+
13+
check:
14+
needs: build
15+
uses: ./.github/workflows/check.yaml
16+
secrets: inherit
17+
18+
e2e-tests:
19+
needs: [build, check]
20+
uses: ./.github/workflows/test-e2e.yaml
21+
secrets: inherit
22+
23+
release:
24+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta')
25+
needs: [build, check, e2e-tests]
26+
permissions:
27+
contents: write
28+
id-token: write
29+
actions: read
30+
uses: ./.github/workflows/release.yaml
31+
secrets:
32+
VAULT_URL: ${{ secrets.VAULT_URL }}

.github/workflows/release.yaml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Release
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
VAULT_URL:
7+
required: true
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
13+
permissions:
14+
contents: write
15+
id-token: write
16+
actions: read
17+
18+
steps:
19+
- name: "Retrieve Secrets from Vault"
20+
id: vault
21+
uses: hashicorp/[email protected]
22+
with:
23+
url: ${{ secrets.VAULT_URL }}
24+
role: ${{ github.event.repository.name }}-github-action
25+
method: jwt
26+
path: github-actions
27+
exportEnv: false
28+
secrets: |
29+
github/token/${{ github.event.repository.name }}-semantic-release token | GITHUB_TOKEN ;
30+
- name: Get Automation Bot User ID
31+
id: get-user-id
32+
run: echo "user-id=$(gh api "/users/contentful-automation[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
33+
env:
34+
GITHUB_TOKEN: ${{ steps.vault.outputs.GITHUB_TOKEN }}
35+
36+
- name: Setting up Git User Credentials
37+
run: |
38+
git config --global user.name 'contentful-automation[bot]'
39+
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+contentful-automation[bot]@users.noreply.github.com'
40+
- name: Checkout code
41+
uses: actions/checkout@v5
42+
with:
43+
fetch-depth: 0
44+
45+
- name: Setup Node.js
46+
uses: actions/setup-node@v6
47+
with:
48+
node-version: "22"
49+
cache: "npm"
50+
51+
- name: Install latest npm
52+
run: npm install -g npm@latest
53+
54+
- name: Install dependencies
55+
run: npm ci
56+
57+
- name: Restore the build folders
58+
uses: actions/cache/restore@v4
59+
with:
60+
path: |
61+
dist
62+
build
63+
key: build-cache-${{ github.run_id }}-${{ github.run_attempt }}
64+
- name: Run Release
65+
run: |
66+
echo "Starting Semantic Release Process"
67+
echo "npm version: $(npm -v)"
68+
npm run semantic-release
69+
env:
70+
GITHUB_TOKEN: ${{ steps.vault.outputs.GITHUB_TOKEN }}
71+
72+
- name: Get latest release tag
73+
id: get-tag
74+
run: |
75+
TAG=$(gh api repos/${{ github.repository }}/releases/latest --jq .tag_name)
76+
echo "tag=$TAG" >> $GITHUB_OUTPUT
77+
env:
78+
GITHUB_TOKEN: ${{ steps.vault.outputs.GITHUB_TOKEN }}
79+
80+
- name: Summary
81+
run: |
82+
VERSION=$(echo "${{ steps.get-tag.outputs.tag }}" | sed 's/^v//')
83+
echo "## Release Summary" >> $GITHUB_STEP_SUMMARY
84+
echo "" >> $GITHUB_STEP_SUMMARY
85+
echo "- **Version**: ${{ steps.get-tag.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
86+
echo "- **GitHub Release**: https://github.com/${{ github.repository }}/releases/tag/${{ steps.get-tag.outputs.tag }}" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)