Skip to content

Commit 7a2e2c6

Browse files
committed
New 1 input and 1 output
1 parent 35993d8 commit 7a2e2c6

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches: ["main"]
66
pull_request:
7-
branches: [ "main" ]
7+
branches: ["main"]
88

99
jobs:
1010
test-non-main-repo:

README.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@ Restore, build, and publish the project, modify index.html to fit the repository
77
## How to use
88
First, set Repository Settings - Pages - Source to GitHub Actions.
99

10-
This action has two inputs and no output.
10+
This action has three inputs and one output.
1111

12-
`project-path`: Path of project (.csproj). Default is (repo name)/(repo name).csproj.
12+
### Inputs
13+
`project-path`: Path of project (.csproj). Default is `(repo name)/(repo name).csproj`.
1314

14-
`main-repo`: Set to true only when running this action from the default GitHub Pages repository ({ID}.github.io). Default is false.
15+
`publish-path`: Path to output in Publish step. It doesn't matter most of the time.
16+
17+
`main-repo`: Set to `true` only when running this action from the default GitHub Pages repository (`{username}.github.io`).
18+
19+
### Outputs
20+
`wwwroot-path`: The resulting `wwwroot` path. It must be passed to `path` in the `upload-pages-artifact` step.
1521

1622
## Example Workflow
1723
```yml

action.yml

+26-5
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,41 @@ inputs:
77
project-path:
88
description: Path of project (.csproj)
99
default: ${{ github.event.repository.name }}/${{ github.event.repository.name }}.csproj
10+
publish-path:
11+
description: Path to output in Publish step
12+
default: _out
1013
main-repo:
1114
description: Set to true only when running this action from the default GitHub Pages repository ({ID}.github.io).
1215
default: false
16+
outputs:
17+
wwwroot-path:
18+
description: Path of wwwroot
19+
value: ${{ steps.wwwroot-output.outputs.wwwroot }}
1320
runs:
1421
using: composite
1522
steps:
16-
- run: dotnet restore ${{ inputs.project-path }}
23+
- name: Restore dependencies
24+
run: dotnet restore ${{ inputs.project-path }}
1725
shell: bash
18-
- run: dotnet build ${{ inputs.project-path }} --no-restore -c Release
26+
27+
- name: Build
28+
run: dotnet build ${{ inputs.project-path }} --no-restore -c Release
1929
shell: bash
20-
- run: dotnet publish ${{ inputs.project-path }} --no-build -c Release -o _out
30+
31+
- name: Publish
32+
run: dotnet publish ${{ inputs.project-path }} --no-build -c Release -o ${{ inputs.publish-path }}
2133
shell: bash
22-
- run: sed -i 's/base href="\/"/base href="\/${{ github.event.repository.name }}\/"/g' _out/wwwroot/index.html
34+
35+
- name: wwwroot-path output
36+
id: wwwroot-output
37+
run: echo "wwwroot=$(echo ${{ inputs.publish-path }}/wwwroot)" >> $GITHUB_OUTPUT
2338
shell: bash
39+
40+
- name: Modify index.html for this repository
2441
if: ${{ inputs.main-repo == 'false' }}
25-
- run: touch _out/wwwroot/.nojekyll
42+
run: sed -i 's/base href="\/"/base href="\/${{ github.event.repository.name }}\/"/g' ${{ steps.wwwroot-output.outputs.wwwroot }}/index.html
43+
shell: bash
44+
45+
- name: Create .nojekyll
46+
run: touch ${{ steps.wwwroot-output.outputs.wwwroot }}/.nojekyll
2647
shell: bash

0 commit comments

Comments
 (0)