From 9861a939351299567d9544328b4f16825eea9744 Mon Sep 17 00:00:00 2001 From: hossainemruz Date: Sat, 9 Dec 2023 02:40:52 +0600 Subject: [PATCH] Refactor workflows Signed-off-by: hossainemruz --- .github/workflows/lighthouse-check.yml | 28 -------- .github/workflows/md-link-check.yaml | 34 ---------- .github/workflows/pull-request.yml | 91 ++++++++++++++++++++++++++ .github/workflows/theme-update.yml | 52 +++++++++++++++ assets/jsconfig.json | 2 +- config.yaml | 6 +- go.mod | 3 +- go.sum | 12 +--- 8 files changed, 150 insertions(+), 78 deletions(-) delete mode 100644 .github/workflows/lighthouse-check.yml delete mode 100644 .github/workflows/md-link-check.yaml create mode 100644 .github/workflows/pull-request.yml create mode 100644 .github/workflows/theme-update.yml diff --git a/.github/workflows/lighthouse-check.yml b/.github/workflows/lighthouse-check.yml deleted file mode 100644 index 67aed33a..00000000 --- a/.github/workflows/lighthouse-check.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Lighthouse -# Run check on pull request -on: [pull_request] - -jobs: - score-check: - runs-on: ubuntu-latest - steps: - - name: Waiting for Netlify Preview - uses: kamranayub/wait-for-netlify-action@v2.1.1 - id: preview - with: - site_name: "toha-guides" - max_timeout: 300 - env: - NETLIFY_TOKEN: ${{secrets.NETLIFY_TOKEN}} - - - name: Run Lighthouse - uses: foo-software/lighthouse-check-action@v10.0.0 - id: lighthouseCheck - with: - accessToken: ${{ secrets.LIGHTHOUSE_TOKEN }} - gitHubAccessToken: ${{secrets.GITHUB_TOKEN}} - emulatedFormFactor: 'all' - prCommentEnabled: true - prCommentSaveOld: false - timeout: 5 - urls: "${{ steps.preview.outputs.url }},${{ steps.preview.outputs.url }}/posts/,${{ steps.preview.outputs.url }}/posts/writing-posts/markdown-syntax/" diff --git a/.github/workflows/md-link-check.yaml b/.github/workflows/md-link-check.yaml deleted file mode 100644 index 58bc1e75..00000000 --- a/.github/workflows/md-link-check.yaml +++ /dev/null @@ -1,34 +0,0 @@ -name: Check Markdown links - -# Run action on pull request event -on: [pull_request] - -jobs: - markdown-link-check: - runs-on: ubuntu-latest - steps: - # checkout to latest commit - - uses: actions/checkout@master - - - name: Waiting for Netlify Preview - uses: kamranayub/wait-for-netlify-action@v2.1.1 - id: preview - with: - site_name: "toha-guides" - max_timeout: 300 - env: - NETLIFY_TOKEN: ${{secrets.NETLIFY_TOKEN}} - - - name: Link Checker - id: lychee - uses: lycheeverse/lychee-action@v1.8.0 - env: - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - with: - args: "--verbose --exclude-mail ${{steps.preview.outputs.url}}" - - - name: Comment Broken Links - uses: marocchino/sticky-pull-request-comment@v2 - if: ${{env.lychee_exit_code != '0'}} - with: - path: lychee/out.md diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 00000000..d4567e6f --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,91 @@ +name: PR Workflows + +# Run action on pull request event +on: [pull_request] + + +jobs: + # Build exampleSite + build: + runs-on: ubuntu-latest + steps: + # checkout to the commit that has been pushed + - uses: actions/checkout@v4.1.1 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Install node modules + run: npm install + + - name: Setup Hugo + uses: peaceiris/actions-hugo@v2.6.0 + with: + hugo-version: 'latest' + extended: true + + - name: Build + run: | + hugo --minify + + + lighthouse-check: + runs-on: ubuntu-latest + steps: + - name: Waiting for Netlify Preview + uses: kamranayub/wait-for-netlify-action@v2.1.1 + id: preview + with: + site_name: "toha-guides" + max_timeout: 300 + env: + NETLIFY_TOKEN: ${{secrets.NETLIFY_TOKEN}} + + - name: Run Lighthouse + uses: foo-software/lighthouse-check-action@v10.0.0 + id: lighthouseCheck + with: + accessToken: ${{ secrets.LIGHTHOUSE_TOKEN }} + gitHubAccessToken: ${{secrets.GITHUB_TOKEN}} + emulatedFormFactor: 'all' + prCommentEnabled: true + prCommentSaveOld: false + timeout: 5 + urls: "${{ steps.preview.outputs.url }},${{ steps.preview.outputs.url }}/posts/,${{ steps.preview.outputs.url }}/posts/markdown-sample/,${{ steps.preview.outputs.url }}/posts/shortcodes/" + + # Check for any broken links + markdown-link-check: + runs-on: ubuntu-latest + steps: + # checkout to latest commit + - uses: actions/checkout@master + + - name: Waiting for Netlify Preview + uses: kamranayub/wait-for-netlify-action@v2.1.1 + id: preview + with: + site_name: "toha-guides" + max_timeout: 300 + env: + NETLIFY_TOKEN: ${{secrets.NETLIFY_TOKEN}} + + - name: Link Checker + id: lychee + uses: lycheeverse/lychee-action@v1.8.0 + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + with: + args: "--verbose --exclude-mail ${{steps.preview.outputs.url}} --exclude=['https://www.udemy.com/']" + output: lychee/out.md + + - name: Comment Broken Links + if: ${{ steps.lychee.outputs.exit_code != 0 }} + uses: marocchino/sticky-pull-request-comment@v2 + with: + path: lychee/out.md + + - name: Fail workflow if broken links found + if: ${{ steps.lychee.outputs.exit_code != 0 }} + run: exit 1 diff --git a/.github/workflows/theme-update.yml b/.github/workflows/theme-update.yml new file mode 100644 index 00000000..4fd9daf1 --- /dev/null +++ b/.github/workflows/theme-update.yml @@ -0,0 +1,52 @@ +name: "Theme Update" + +on: + schedule: + - cron: "0 0 * * *" + +jobs: + update-theme: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.1 + with: + ref: main + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Setup Hugo + uses: peaceiris/actions-hugo@v2.6.0 + with: + hugo-version: "latest" + extended: true + + - name: Update hugo modules + run: | + # update to latest version of all modules + hugo mod get -u + + # update the npm dependencies + hugo mod npm pack + + # cleanup go.sum file + hugo mod tidy + + - name: Install node modules + run: npm install + + - name: Build + run: | + # build the site + hugo --minify + # remove file generated by the build + rm -rf public/ + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + base: main + title: Update theme + labels: automerge diff --git a/assets/jsconfig.json b/assets/jsconfig.json index 895c37c8..6bafc06d 100644 --- a/assets/jsconfig.json +++ b/assets/jsconfig.json @@ -3,7 +3,7 @@ "baseUrl": ".", "paths": { "*": [ - "../../../../../.cache/hugo_cache/modules/filecache/modules/pkg/mod/github.com/hugo-toha/toha/v4@v4.0.0-20230929231747-c943f39617c1/assets/*" + "../../../../../.cache/hugo_cache/modules/filecache/modules/pkg/mod/github.com/hugo-toha/toha/v4@v4.0.0/assets/*" ] } } diff --git a/config.yaml b/config.yaml index e2849781..dbc71f6c 100644 --- a/config.yaml +++ b/config.yaml @@ -272,9 +272,9 @@ params: # Show/hide newsletter section in the footer. Default is "true". # Currently, it supports "mailchimp". newsletter: - enable: true - provider: mailchimp - mailchimpURL: https://github.us1.list-manage.com/subscribe/post?u=19de52a4603135aae97163fd8&id=094a24c76e + enable: false + # provider: mailchimp + # mailchimpURL: https://github.us1.list-manage.com/subscribe/post?u=19de52a4603135aae97163fd8&id=094a24c76e # Show/hide disclaimer notice in the footer. Default is "false". disclaimer: diff --git a/go.mod b/go.mod index 7b1e30aa..cda093fb 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,5 @@ go 1.19 // replace github.com/hugo-toha/toha/v3 => ../toha require ( - github.com/hugo-toha/toha/v4 v4.0.0-20231031071528-05c9d3d850b2 // indirect - github.com/hugofy/hugofy v0.0.0-20230215174605-0af4f57bf558 // indirect + github.com/hugo-toha/toha/v4 v4.0.0 // indirect ) diff --git a/go.sum b/go.sum index 86a12aaf..02cb7e8e 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,2 @@ -github.com/hugo-toha/toha/v4 v4.0.0-20230728200917-0e12222cc3bd h1:cSPVhSQLd3CI+QnVl/tpMSKJm50+nYJL/qtAYrUdNkE= -github.com/hugo-toha/toha/v4 v4.0.0-20230728200917-0e12222cc3bd/go.mod h1:p/K34lqlqmhzfPd4cx66od7sjlROBqhMxG30mJz+aKQ= -github.com/hugo-toha/toha/v4 v4.0.0-20230929231747-c943f39617c1 h1:iPPEerrlIaBH5TvkQSQ71Rg09C5GvGVodM0WOiipUcc= -github.com/hugo-toha/toha/v4 v4.0.0-20230929231747-c943f39617c1/go.mod h1:p/K34lqlqmhzfPd4cx66od7sjlROBqhMxG30mJz+aKQ= -github.com/hugo-toha/toha/v4 v4.0.0-20231030042714-e61d6b796b48 h1:/3ICPbsN9zTOmIQqSmzVdMCShucO22LgZyPIQhd4yBg= -github.com/hugo-toha/toha/v4 v4.0.0-20231030042714-e61d6b796b48/go.mod h1:p/K34lqlqmhzfPd4cx66od7sjlROBqhMxG30mJz+aKQ= -github.com/hugo-toha/toha/v4 v4.0.0-20231031071528-05c9d3d850b2 h1:EkR94Ztv1Ao+iEP0e5Vk/GRmZvhAjSHzjsMOXBaK3Ak= -github.com/hugo-toha/toha/v4 v4.0.0-20231031071528-05c9d3d850b2/go.mod h1:p/K34lqlqmhzfPd4cx66od7sjlROBqhMxG30mJz+aKQ= -github.com/hugofy/hugofy v0.0.0-20230215174605-0af4f57bf558 h1:x3Ey1ITCOjhFaCUjubPRAhTTYQw2+g27NuQMqdq8xR8= -github.com/hugofy/hugofy v0.0.0-20230215174605-0af4f57bf558/go.mod h1:5g0QdEPA4ThSe+v5ZGKLfPwrfqiz2mq8mAB8HXI0Trw= +github.com/hugo-toha/toha/v4 v4.0.0 h1:rOiQeXzppzBLslTcQ1q2cqtz4KrjvYsrEVAHClbnsU8= +github.com/hugo-toha/toha/v4 v4.0.0/go.mod h1:p/K34lqlqmhzfPd4cx66od7sjlROBqhMxG30mJz+aKQ=