Skip to content

Commit f3a4ad9

Browse files
authored
ci: Fix a11y and other Action workflows (#1299)
1 parent 68df8fc commit f3a4ad9

11 files changed

+170
-147
lines changed

.github/workflows/deploy-package.yml

+73-43
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,20 @@ on:
77
description: Deployment environment
88
type: choice
99
options:
10-
- staging
10+
- pkg.github.com
1111
- nuget.org
12-
default: staging
12+
default: pkg.github.com
1313
required: true
1414
preview:
1515
description: Append preview suffix
1616
type: boolean
1717
default: true
1818
required: true
19+
dry_run:
20+
description: 'Dry-run only (no deploy)'
21+
type: boolean
22+
default: true
23+
required: true
1924

2025
concurrency:
2126
group: ${{ inputs.environment }}
@@ -34,6 +39,12 @@ jobs:
3439
with:
3540
fetch-depth: 0
3641

42+
- name: Setup .NET
43+
uses: actions/setup-dotnet@v4
44+
with:
45+
dotnet-version: "9.x"
46+
dotnet-quality: "ga"
47+
3748
- name: Setup GitVersion
3849
uses: gittools/actions/gitversion/[email protected]
3950
with:
@@ -51,21 +62,19 @@ jobs:
5162
- name: Compose version
5263
id: compose
5364
run: |
54-
ver=${{ steps.gitversion.outputs.majorMinorPatch }}${{ inputs.preview && '-preview.' || '' }}${{ inputs.preview && steps.gitversion.outputs.preReleaseNumber || inputs.preview && github.run_number || '' }}
55-
echo "version=$ver" >> "$GITHUB_OUTPUT"
65+
# get base version
66+
base="${{ steps.gitversion.outputs.majorMinorPatch }}"
5667
57-
- name: Update release notes URL
58-
uses: jacobtomlinson/gha-find-replace@v3
59-
with:
60-
find: "<PackageReleaseNotes>https://github.com/DaveSkender/Stock.Indicators/releases</PackageReleaseNotes>"
61-
replace: "<PackageReleaseNotes>https://github.com/DaveSkender/Stock.Indicators/releases/tag/${{ steps.compose.outputs.version }}</PackageReleaseNotes>"
62-
regex: false
68+
# determine preview suffix
69+
preview_tag="${{ inputs.preview && '-preview.' || '' }}"
6370
64-
- name: Setup .NET
65-
uses: actions/setup-dotnet@v4
66-
with:
67-
dotnet-version: "9.x"
68-
dotnet-quality: "ga"
71+
# determine preview number
72+
preview_num="${{ inputs.preview && steps.gitversion.outputs.preReleaseNumber || '' }}"
73+
74+
# combine all parts
75+
ver="${base}${preview_tag}${preview_num}"
76+
77+
echo "version=$ver" >> "$GITHUB_OUTPUT"
6978
7079
- name: Build library
7180
run: >
@@ -106,28 +115,18 @@ jobs:
106115
deploy:
107116
needs: build
108117
runs-on: ubuntu-latest
118+
if: success()
109119

110120
permissions:
111121
contents: write
112122
packages: write
113123

114124
environment:
115-
name: ${{ inputs.environment }}
116-
url: "${{ vars.NUGET_DOWNLOAD_PREFIX }}${{ needs.build.outputs.version }}"
125+
name: ${{ !inputs.dry_run && inputs.environment || '' }}
126+
url: ${{ steps.package_info.outputs.url }}
117127

118128
steps:
119129

120-
- name: Pre-flight summary
121-
run: |
122-
{
123-
echo "| Parameter | Value |"
124-
echo "| :-------------- | :--------------------------------- |"
125-
echo "| Environment | ${{ inputs.environment }} |"
126-
echo "| Publishing URL | ${{ vars.NUGET_PUBLISH_URL }} |"
127-
echo "| Download URL | ${{ vars.NUGET_DOWNLOAD_PREFIX }} |"
128-
echo "| Version ID | ${{ needs.build.outputs.version }} |"
129-
} >> $GITHUB_STEP_SUMMARY
130-
131130
- name: Setup .NET
132131
uses: actions/setup-dotnet@v4
133132
with:
@@ -146,28 +145,59 @@ jobs:
146145
name: packages
147146
path: NuGet
148147

149-
- name: Publish to GitHub Packages (staging)
150-
if: inputs.environment == 'staging'
151-
run: |
152-
dotnet nuget push NuGet/*.nupkg --source "https://nuget.pkg.github.com/DaveSkender/index.json" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
153-
154-
- name: Publish to NuGet.org
155-
if: inputs.environment == 'nuget.org'
148+
- name: Compose package info
149+
id: package_info
156150
run: |
157-
dotnet new nugetconfig --force
158-
nuget setApiKey ${{ secrets.NUGET_TOKEN }} -src nuget -ConfigFile nuget.config
159-
nuget push NuGet/*.nupkg -src nuget -NonInteractive -ConfigFile nuget.config -Verbosity Detailed
151+
PACKAGE_NAME=$(xmllint --xpath "//PropertyGroup/PackageId/text()" Directory.Build.props || xmllint --xpath "//PropertyGroup/PackageId/text()" **/*.csproj)
152+
echo "pkg_name=${PACKAGE_NAME}" >> $GITHUB_OUTPUT
153+
if [[ "${{ inputs.environment }}" == "nuget.org" ]]; then
154+
echo "pkg_url=https://www.nuget.org/packages/${PACKAGE_NAME}/${{ needs.build.outputs.version }}" >> $GITHUB_OUTPUT
155+
else
156+
echo "pkg_url=https://github.com/${{ github.repository }}/packages/nuget/${PACKAGE_NAME}/${{ needs.build.outputs.version }}" >> $GITHUB_OUTPUT
157+
fi
158+
159+
- name: Publish package
160+
if: ${{ !inputs.dry_run }}
161+
env:
162+
API_KEY: ${{ inputs.environment == 'nuget.org' && secrets.NUGET_TOKEN || secrets.GITHUB_TOKEN }}
163+
run: >
164+
dotnet nuget push NuGet/*.nupkg
165+
--source "${{ vars.NUGET_PUBLISH_URL }}"
166+
--api-key "$API_KEY"
167+
--skip-duplicate
160168
161169
- name: Tag and draft release note
162170
uses: ncipollo/release-action@v1
163-
if: inputs.environment == 'nuget.org'
171+
if: ${{ !inputs.dry_run && inputs.environment == 'nuget.org' }}
164172
with:
165173
body: |
166-
We’ve released a new Stock Indicators for .NET NuGet package.
167-
See [Skender.Stock.Indicators @ NuGet.org](${{ vars.NUGET_DOWNLOAD_PREFIX }}${{ needs.build.outputs.version }}) for more information.
174+
## Release ${{ needs.build.outputs.version }}
175+
176+
📦 Package deployed to [${{ inputs.environment }}](${{ steps.package_info.outputs.pkg_url }})
177+
178+
### Package Details
179+
- **Name**: ${{ steps.package_info.outputs.pkg_name }}
180+
- **Version**: ${{ needs.build.outputs.version }}
181+
- **Preview**: ${{ inputs.preview && 'Yes' || 'No' }}
168182
generateReleaseNotes: true
169183
draft: true
170184
makeLatest: ${{ !inputs.preview }}
171185
prerelease: ${{ inputs.preview }}
172-
tag: ${{ needs.build.outputs.version }}
173-
commit: ${{ github.ref_name }}
186+
tag: v${{ needs.build.outputs.version }}
187+
commit: ${{ github.sha }}
188+
token: ${{ secrets.GITHUB_TOKEN }}
189+
190+
- name: Deployment summary
191+
if: always()
192+
run: |
193+
{
194+
echo "## Package Deployment"
195+
echo "| Parameter | Value |"
196+
echo "|:------------|:------|"
197+
echo "| Mode | ${{ inputs.dry_run && '🔍 DRY RUN' || '🚀 DEPLOY' }} |"
198+
echo "| Status | ${{ job.status == 'success' && '✅ Success' || '❌ Failed' }} |"
199+
echo "| Environment | ${{ inputs.environment }} |"
200+
echo "| Version | ${{ needs.build.outputs.version }} |"
201+
echo "| Package | [${{ steps.package_info.outputs.pkg_name }}](${{ steps.package_info.outputs.pkg_url }}) |"
202+
echo "| Preview | ${{ inputs.preview && '✓' || '✗' }} |"
203+
} >> $GITHUB_STEP_SUMMARY

.github/workflows/deploy-website.yml

+10-14
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ jobs:
1212
deploy:
1313
name: Cloudflare Pages
1414
runs-on: ubuntu-latest
15+
defaults:
16+
run:
17+
working-directory: docs
18+
env:
19+
BUNDLE_GEMFILE: ${{github.workspace}}/docs/Gemfile
20+
JEKYLL_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1521

1622
environment:
1723
name: stockindicators.dev
18-
url: ${{ steps.deploy.outputs.deployment-alias-url }}
24+
url: ${{ steps.deploy.outputs.pages-deployment-alias-url }}
1925

2026
steps:
2127
- name: Checkout source
@@ -24,9 +30,11 @@ jobs:
2430
- name: Setup Ruby
2531
uses: ruby/setup-ruby@v1
2632
with:
27-
working-directory: docs
2833
ruby-version: 3.3
2934

35+
- name: Install dependencies
36+
run: bundle install
37+
3038
- name: Define tag
3139
id: tag
3240
run: echo "version=$(date +'%Y.%m.%d')-${{ github.run_number }}" >> $GITHUB_OUTPUT
@@ -38,28 +46,16 @@ jobs:
3846
replace: "${{ steps.tag.outputs.version }}"
3947
regex: false
4048

41-
- name: Install GEMs
42-
working-directory: docs
43-
env:
44-
BUNDLE_GEMFILE: ${{github.workspace}}/docs/GemFile
45-
run: |
46-
pwd
47-
bundle install
48-
4949
- name: Build site (production)
5050
if: github.ref == 'refs/heads/main'
51-
working-directory: docs
5251
env:
5352
JEKYLL_ENV: production
54-
BUNDLE_GEMFILE: ${{github.workspace}}/docs/GemFile
5553
run: bundle exec jekyll build
5654

5755
- name: Build site (preview)
5856
if: github.ref != 'refs/heads/main'
59-
working-directory: docs
6057
env:
6158
JEKYLL_ENV: preview
62-
BUNDLE_GEMFILE: ${{github.workspace}}/docs/GemFile
6359
run: bundle exec jekyll build
6460

6561
- name: Publish to Cloudflare Pages

.github/workflows/lint-pull-request.yml

+14-17
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
main:
1515
name: lint PR title
1616
runs-on: ubuntu-latest
17+
1718
steps:
1819
- uses: amannn/action-semantic-pull-request@v5
1920
id: lint_pr_title
@@ -29,9 +30,8 @@ jobs:
2930
# the default error message that is shown when the pattern doesn't match.
3031
# The variables `subject` and `title` can be used within the message.
3132
subjectPatternError: >
32-
The subject "**{subject}**" found in the pull request title "*{title}*"
33-
didn't match the configured pattern. Please ensure that the subject
34-
starts with an uppercase character.
33+
The subject "**{subject}**" in pull request "*{title}*"
34+
needs to start with an uppercase character.
3535
3636
# If the PR contains one of these newline-delimited labels, the
3737
# validation is skipped. If you want to rerun the validation when
@@ -48,24 +48,21 @@ jobs:
4848
with:
4949
header: pr-title-lint-error
5050
message: |
51-
### Hey there and thank you for opening this pull request! 👋🏼
52-
53-
It looks like your proposed **_Pull request title_** needs to be adjusted.
54-
55-
>🚩 **Error** » ${{ steps.lint_pr_title.outputs.error_message }}
51+
### ⚠️ Pull Request title needs adjustment
5652
57-
#### Pull request title naming convention
53+
Your PR title doesn't match our naming convention: `type: Subject`
5854
59-
Our PR title name taxonomy is `type: Subject`, where **type** is typically
60-
*feat*, *fix*, or *chore*, and **subject** is a phrase (proper noun) that starts
61-
with a capitalized letter. The *chore* type usually has a subject that starts
62-
with an action verb like *Add* or *Update*. Examples:
55+
> [!CAUTION]
56+
> ${{ steps.lint_pr_title.outputs.error_message }}
6357
64-
- _feat: Admin portal login_
65-
- _fix: Divide by zero in X calculation_
66-
- _chore: Update packages_
67-
- _docs: Improve setup guidance_
58+
#### Valid examples
6859
60+
- `feat: Add new RSI indicator`
61+
- `fix: Correct MACD calculation`
62+
- `chore: Update documentation`
63+
- `test: Add unit tests for EMA`
64+
- `refactor: Optimize moving average logic`
65+
6966
See the [Conventional Commits specification](https://www.conventionalcommits.org) for more information.
7067
7168
# Delete a previous comment when the issue has been resolved

.github/workflows/lock-issues-pr.yml

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ concurrency:
1616
jobs:
1717
lock:
1818
runs-on: ubuntu-latest
19+
timeout-minutes: 10
20+
1921
steps:
2022
- uses: dessant/lock-threads@v5
2123
with:

.github/workflows/test-website-a11y.yml

+25-20
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,23 @@ on:
44
pull_request:
55
branches: ["*"]
66
paths:
7-
- 'docs/**'
8-
- ".github/workflows/test-website-a11y.yml"
7+
- docs/**
8+
- .github/workflows/test-website-a11y.yml
99

10-
env:
11-
JEKYLL_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10+
# Prevent multiple concurrent runs
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
1214

1315
jobs:
1416
test:
15-
name: test
1617
runs-on: ubuntu-latest
17-
18+
defaults:
19+
run:
20+
working-directory: docs
1821
env:
19-
BUNDLE_GEMFILE: ${{github.workspace}}/docs/GemFile
22+
BUNDLE_GEMFILE: ${{github.workspace}}/docs/Gemfile
23+
JEKYLL_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2024

2125
steps:
2226
- name: Checkout source
@@ -25,33 +29,34 @@ jobs:
2529
- name: Setup Ruby
2630
uses: ruby/setup-ruby@v1
2731
with:
28-
working-directory: docs
2932
ruby-version: 3.3
3033

31-
- name: Install GEMs
32-
working-directory: docs
34+
- name: Install dependencies
3335
run: |
34-
pwd
3536
bundle install
37+
npm install -g pa11y-ci
38+
39+
- name: Use 'localhost'
40+
uses: jacobtomlinson/gha-find-replace@v3
41+
with:
42+
find: "https://dotnet.stockindicators.dev"
43+
replace: "http://127.0.0.1:4000"
44+
regex: false
3645

3746
- name: Build site
38-
working-directory: docs
3947
run: bundle exec jekyll build
4048

4149
- name: Serve site
42-
working-directory: docs
43-
run: bundle exec jekyll serve --detach
50+
run: bundle exec jekyll serve --port 4000 --detach
4451

4552
- name: Show environment
46-
working-directory: docs
4753
run: npx pa11y --environment
4854

4955
- name: Test accessibility
50-
working-directory: docs
51-
run: |
52-
npx pa11y-ci \
53-
--sitemap http://127.0.0.1:4000/sitemap.xml \
54-
--sitemap-exclude "/*.pdf"
56+
run: >
57+
pa11y-ci
58+
--sitemap http://127.0.0.1:4000/sitemap.xml
59+
--config ./.pa11yci
5560
5661
- name: Kill site (failsafe)
5762
if: always()

0 commit comments

Comments
 (0)