Skip to content

Commit

Permalink
polish workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
B4nan committed Nov 26, 2024
1 parent bf985de commit 666581f
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 90 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/apiary.yaml

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ jobs:
registry-url: 'https://npm.pkg.github.com/'
scope: '@apify-packages'

- name: Enable corepack
run: |
corepack enable
- name: Enable corepack
run: |
corepack enable
- name: Build docs
run: |
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/lychee.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ jobs:
registry-url: 'https://npm.pkg.github.com/'
scope: '@apify-packages'

- name: Enable corepack
run: |
corepack enable
- name: Build docs
run: |
npm ci --force
Expand Down
122 changes: 66 additions & 56 deletions .github/workflows/publish-theme.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,33 @@ on:

jobs:
look_for_change:
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
runs-on: ubuntu-latest
outputs:
theme_changed: ${{ steps.changed-theme-files.outputs.any_changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22

- name: Check changes in theme
id: changed-theme-files
uses: tj-actions/changed-files@v45
with:
since_last_remote_commit: "true"
files: |
apify-docs-theme/**
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
runs-on: ubuntu-latest
outputs:
theme_changed: ${{ steps.changed-theme-files.outputs.any_changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'npm'
cache-dependency-path: 'package-lock.json'

- name: Enable corepack
run: |
corepack enable
- name: Check changes in theme
id: changed-theme-files
uses: tj-actions/changed-files@v45
with:
since_last_remote_commit: "true"
files: |
apify-docs-theme/**
publish:
needs: look_for_change
Expand All @@ -47,6 +53,10 @@ jobs:
cache-dependency-path: 'package-lock.json'
always-auth: 'true'

- name: Enable corepack
run: |
corepack enable
- name: Setup git user and npm
run: |
git config --global user.name "Apify Release Bot"
Expand All @@ -70,33 +80,33 @@ jobs:
GIT_USER: "barjin:${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}"
GH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}

- name: Wait until the new theme version is available on npm
run: |
cd $GITHUB_WORKSPACE/apify-docs-theme
PACKAGE_JSON=$(cat package.json);
PACKAGE_NAME=$(jq -r .name <(echo $PACKAGE_JSON));
PACKAGE_VER=$(jq -r .version <(echo $PACKAGE_JSON));
for i in $(seq 1 10); do
EXIT_CODE=0;
npm show $PACKAGE_NAME@$PACKAGE_VER || EXIT_CODE=1;
if [[ $EXIT_CODE -eq 1 ]]; then
echo "The new package version ($PACKAGE_VER) is not yet available, waiting 30 seconds...";
sleep 30;
continue;
fi;
echo "The new package version ($PACKAGE_VER) is live, proceeding!";
break;
done;
npm show $PACKAGE_NAME@$PACKAGE_VER # fails if the package is not available, succeeds if it is
- name: Commit the new theme version
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'chore: publish new version of @apify/docs-theme [skip ci]'
file_pattern: 'apify-docs-theme/package*.json'
commit_user_name: Apify Bot
commit_user_email: my-github-actions-bot@example.org
commit_author: Apify Bot <apify@apify.com>
- name: Wait until the new theme version is available on npm
run: |
cd $GITHUB_WORKSPACE/apify-docs-theme
PACKAGE_JSON=$(cat package.json);
PACKAGE_NAME=$(jq -r .name <(echo $PACKAGE_JSON));
PACKAGE_VER=$(jq -r .version <(echo $PACKAGE_JSON));
for i in $(seq 1 10); do
EXIT_CODE=0;
npm show $PACKAGE_NAME@$PACKAGE_VER || EXIT_CODE=1;
if [[ $EXIT_CODE -eq 1 ]]; then
echo "The new package version ($PACKAGE_VER) is not yet available, waiting 30 seconds...";
sleep 30;
continue;
fi;
echo "The new package version ($PACKAGE_VER) is live, proceeding!";
break;
done;
npm show $PACKAGE_NAME@$PACKAGE_VER # fails if the package is not available, succeeds if it is
- name: Commit the new theme version
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'chore: publish new version of @apify/docs-theme [skip ci]'
file_pattern: 'apify-docs-theme/package*.json'
commit_user_name: Apify Bot
commit_user_email: my-github-actions-bot@example.org
commit_author: Apify Bot <apify@apify.com>

rebuild-docs:
needs: publish
Expand All @@ -109,10 +119,10 @@ jobs:

runs-on: ubuntu-latest
steps:
- env:
GITHUB_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
run: |
gh workflow run docs.yaml --repo ${{ matrix.repo }}
- env:
GITHUB_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
run: |
gh workflow run docs.yaml --repo ${{ matrix.repo }}
rebuild-python-docs:
needs: publish
Expand All @@ -124,7 +134,7 @@ jobs:

runs-on: ubuntu-latest
steps:
- env:
GITHUB_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
run: |
gh workflow run build_and_deploy_docs.yaml --repo ${{ matrix.repo }}
- env:
GITHUB_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
run: |
gh workflow run build_and_deploy_docs.yaml --repo ${{ matrix.repo }}
8 changes: 2 additions & 6 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,9 @@ module.exports = {
// '@docusaurus/plugin-client-redirects',
// {
// createRedirects(existingPath) {
// // TODO change to `api/v2` once we are ready
// if (existingPath.endsWith('api/v2-new')) {
// return `${existingPath}/api/v2-new/apify-api`;
// if (!existingPath.endsWith('/')) {
// return `${existingPath}/`;
// }
// // if (!existingPath.endsWith('/')) {
// // return `${existingPath}/`;
// // }
//
// return undefined; // Return a falsy value: no redirect created
// },
Expand Down

0 comments on commit 666581f

Please sign in to comment.