Skip to content

Commit b9c85da

Browse files
authored
Merge pull request #351 from AdobeDocs/ds_pr-test-wf
Convert test-pull-request workflow to reusable
2 parents e0356ff + 03c0217 commit b9c85da

File tree

4 files changed

+60
-94
lines changed

4 files changed

+60
-94
lines changed

.github/workflows/add-to-project-board.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ on:
1212

1313
jobs:
1414
call-workflow-add-to-project:
15-
uses: AdobeDocs/commerce-php/.github/workflows/add-to-project_job.yml@main
15+
uses: ./.github/workflows/add-to-project_job.yml
1616
secrets: inherit

.github/workflows/github-pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ defaults:
1717

1818
jobs:
1919
call-workflow-deploy-to-pages:
20-
uses: AdobeDocs/commerce-php/.github/workflows/deploy-to-pages_job.yml@main
20+
uses: ./.github/workflows/deploy-to-pages_job.yml
Lines changed: 5 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,12 @@
11
---
2-
###########################
3-
###########################
4-
## Pull request testing ##
5-
###########################
6-
###########################
72
name: Validate pull request
83

9-
# Documentation:
10-
# - Workflow: https://help.github.com/en/articles/workflow-syntax-for-github-actions
11-
# - SuperLinter: https://github.com/github/super-linter
12-
# - Link validation: https://github.com/remarkjs/remark-validate-links
13-
14-
######################################################
15-
# Start the job on a pull request to the main branch #
16-
######################################################
174
on: pull_request
185

19-
#################################################
20-
# Disable all permissions on the workflow level #
21-
#################################################
22-
permissions: {}
6+
permissions:
7+
contents: read
8+
statuses: write
239

24-
###############
25-
# Set the Job #
26-
###############
2710
jobs:
28-
lint:
29-
# Set the agent to run on
30-
runs-on: ubuntu-latest
31-
32-
############################################
33-
# Grant status permission for MULTI_STATUS #
34-
############################################
35-
permissions:
36-
contents: read
37-
statuses: write
38-
39-
##################
40-
# Load all steps #
41-
##################
42-
steps:
43-
##########################
44-
# Checkout the code base #
45-
##########################
46-
- name: Checkout Code
47-
uses: actions/checkout@v4
48-
with:
49-
# Full git history is needed to get a proper list of changed files
50-
# within `super-linter`
51-
fetch-depth: 0
52-
- name: Load super-linter configuration
53-
run: cat .github/super-linter.env >> "$GITHUB_ENV"
54-
55-
################################
56-
# Run Linters against code base #
57-
################################
58-
- name: Lint Code Base
59-
#
60-
# Use full version number to avoid cases when a next
61-
# released version is buggy
62-
# About slim image: https://github.com/github/super-linter#slim-image
63-
uses: super-linter/super-linter/[email protected]
64-
env:
65-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66-
67-
test:
68-
runs-on: ubuntu-latest
69-
needs: lint
70-
permissions:
71-
contents: read
72-
statuses: write
73-
steps:
74-
- uses: actions/checkout@v4
75-
- name: Use Setup Node and Install Dependencies Action
76-
uses: commerce-docs/devsite-install-action@main
77-
with:
78-
node-version-file: '.nvmrc'
79-
cache-dependency-path: 'yarn.lock'
80-
81-
- name: Check links
82-
run: yarn test
83-
84-
build:
85-
runs-on: ubuntu-latest
86-
needs: test
87-
permissions:
88-
contents: read
89-
statuses: write
90-
steps:
91-
- uses: actions/checkout@v4
92-
- name: Use Setup Node and Install Dependencies Action
93-
uses: commerce-docs/devsite-install-action@main
94-
with:
95-
node-version-file: '.nvmrc'
96-
cache-dependency-path: 'yarn.lock'
97-
98-
- name: Build site
99-
run: yarn build
11+
testing:
12+
uses: ./.github/workflows/validate-pr_job.yml
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
name: Reusable workflow to validate a pull request
3+
4+
on: workflow_call
5+
6+
permissions:
7+
contents: read
8+
statuses: write
9+
10+
jobs:
11+
lint-test:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout Code
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
- name: Load super-linter configuration
20+
run: cat .github/super-linter.env >> "$GITHUB_ENV"
21+
22+
- name: Lint Code Base
23+
uses: super-linter/super-linter/[email protected]
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
27+
remark-test:
28+
runs-on: ubuntu-latest
29+
needs: lint-test
30+
steps:
31+
- uses: actions/checkout@v4
32+
- name: Use Setup Node and Install Dependencies Action
33+
uses: commerce-docs/devsite-install-action@main
34+
with:
35+
node-version-file: '.nvmrc'
36+
cache-dependency-path: 'yarn.lock'
37+
38+
- name: Check links
39+
run: yarn test
40+
41+
build-test:
42+
runs-on: ubuntu-latest
43+
needs: remark-test
44+
steps:
45+
- uses: actions/checkout@v4
46+
- name: Use Setup Node and Install Dependencies Action
47+
uses: commerce-docs/devsite-install-action@main
48+
with:
49+
node-version-file: '.nvmrc'
50+
cache-dependency-path: 'yarn.lock'
51+
52+
- name: Build site
53+
run: yarn build

0 commit comments

Comments
 (0)