Skip to content

Commit

Permalink
fix(ci): use Create Issue From File (#1437)
Browse files Browse the repository at this point in the history
  • Loading branch information
PoisonPhang authored Feb 25, 2024
2 parents 25bca63 + f05f20d commit d65b68a
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 82 deletions.
77 changes: 17 additions & 60 deletions .github/workflows/check-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ name: Links Checker
on:
workflow_dispatch:
repository_dispatch:
# fail fast
push:
branches:
- main
pull_request:
branches:
- main
# daily check
schedule:
- cron: '00 18 * * *'
Expand All @@ -22,46 +15,6 @@ env:
ACTIONS_RUNNER_DEBUG: true

jobs:
# runs on push and pull request
link-checker:
name: '🔗 Check Links'
runs-on: ['ubuntu-latest']
permissions:
contents: read
pull-requests: write
if: github.event_name == 'push' || github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
with:
lfs: true

- name: Link Check
id: lychee
uses: lycheeverse/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: |
site/src app/src --config ${{ github.workspace }}/lychee.toml --github-token ${{ secrets.GITHUB_TOKEN }}
- name: Comment On Pull Request
uses: actions/github-script@v7
# only comment if there are errors and it's a pull request
if: env.lychee_exit_code != 0 && github.event_name == 'pull_request'
# temporarily allow this to fail until we're able to handle these two links: https://github.com/unionlabs/union/actions/runs/8014925873/attempts/1#summary-21894317581
continue-on-error: true
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('node:fs');
const content = fs.readFileSync('./lychee/out.md', { encoding: 'utf8' });
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: content
});
# runs once daily
daily-link-checker:
name: '🔗 Check Links'
runs-on: ['ubuntu-latest']
Expand All @@ -74,26 +27,30 @@ jobs:
with:
lfs: true

- name: Install Nix
uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:${{ env.NIXPKGS_CHANNEL }}
github_access_token: ${{ github.token }}

- name: Build Site
run: nix build .#site

- name: Link Check
id: lychee
uses: lycheeverse/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: |
site/src app/src --config ${{ github.workspace }}/lychee.toml --github-token ${{ secrets.GITHUB_TOKEN }}
--no-progress
'result/**/index.html'
- name: Create Issue From File
uses: actions/github-script@v7
if: env.lychee_exit_code != 0
uses: peter-evans/create-issue-from-file@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('node:fs');
const content = fs.readFileSync('./lychee/out.md', { encoding: 'utf8' });
github.issues.create({
repo: context.repo.repo,
owner: context.repo.owner,
title: 'Link Checker Report',
body: content,
labels: ['report', 'automated issue']
});
title: Link Checker Report
content-filepath: ./lychee/out.md
labels: |
documentation
dead-links
30 changes: 29 additions & 1 deletion .github/workflows/deploy-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ env:
jobs:
deploy-preview:
runs-on: ['ubuntu-latest']
permissions: write-all
permissions:
contents: read
pull-requests: write
env:
npm_config_yes: true
environment: 'site-preview'
Expand Down Expand Up @@ -55,6 +57,32 @@ jobs:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_WORKERS_API_TOKEN }}
run: npx --yes wrangler@latest pages --project-name="site" deploy result >> /tmp/site_deploy.txt

- name: Link Check
id: lychee
uses: lycheeverse/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: |
'result/**/index.html'
- name: Comment On Pull Request
uses: actions/github-script@v7
# only comment if there are errors and it's a pull request
if: env.lychee_exit_code != 0
# temporarily allow this to fail until we're able to handle these two links: https://github.com/unionlabs/union/actions/runs/8014925873/attempts/1#summary-21894317581
continue-on-error: true
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('node:fs');
const content = fs.readFileSync('./lychee/out.md', { encoding: 'utf8' });
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: content
});
- name: Set Deploy Output
run: |
{
Expand Down
1 change: 0 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@
jq
go-ethereum
marksman
lychee
nil
nixfmt
nix-tree
Expand Down
21 changes: 2 additions & 19 deletions lychee.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,10 @@
accept = [200, 429, 307]
base = "result"
exclude = [
'^https://x.com/',
'.woff2$',
'^https://statesync.testnet.bonlulu.uno/',
'^https://grpc.testnet.bonlulu.uno/',
'^http://myserver.com:1111/',
'^https://github.com/unionlabs/union/', # validated by astro
# too stubborn of a page but we manually validated it
'^https://math.mit.edu/research/highschool/primes/materials/2018/Kuszmaul.pdf',
'^CHANGELOG.md$',
'^**/node_modules$',
'^node_modules$',
]

exclude_all_private = true
exclude_path = [
"result",
"node_modules",
"build",
"dist",
"target",
"**/node_modules",
"**/build",
"**/dist",
"**/target",
]
timeout = 20
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Take note of your `address` here and continue to [Receiving Testnet Tokens](#rec

## Receiving Testnet Tokens

Those interested can submit their Union address to the Subo Survey Bot on [our Discord](https://discord.gg/union-build) to have a chance of being selected as a validator and receiving tokens from the Union team.
Those interested can submit their Union address to the Subo Survey Bot on [our Discord](https://discord.union.build) to have a chance of being selected as a validator and receiving tokens from the Union team.

:::note

Expand Down

0 comments on commit d65b68a

Please sign in to comment.