Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/actions/upload-art…
Browse files Browse the repository at this point in the history
…ifact-4
  • Loading branch information
tyrann0us authored Sep 5, 2024
2 parents 2d68fe8 + db67323 commit 2d69b4c
Show file tree
Hide file tree
Showing 19 changed files with 18,563 additions and 103 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @tyrann0us @Chrico
14 changes: 14 additions & 0 deletions .github/workflows/_lint-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Lint documentation

on:
push:
paths:
- '**.md'
pull_request:
workflow_dispatch:

jobs:
wp-scripts-lint:
uses: inpsyde/reusable-workflows/.github/workflows/wp-scripts-lint.yml@main
with:
LINT_TOOLS: '["md-docs"]'
66 changes: 63 additions & 3 deletions .github/workflows/automatic-release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
name: Automatic Release
on:
workflow_call:
inputs:
NPM_REGISTRY_DOMAIN:
description: Domain of the private npm registry.
default: https://npm.pkg.github.com/
required: false
type: string
secrets:
NPM_REGISTRY_TOKEN:
description: Authentication for the private npm registry.
required: false
GITHUB_USER_EMAIL:
description: Email address for the GitHub user configuration.
required: false
GITHUB_USER_NAME:
description: Username for the GitHub user configuration.
required: false
GITHUB_USER_SSH_KEY:
description: Private SSH key associated with the GitHub user for the token passed as `GITHUB_USER_TOKEN`.
required: false
GITHUB_USER_SSH_PUBLIC_KEY:
description: Public SSH key associated with the GitHub user for the token passed as `GITHUB_USER_TOKEN`.
required: false
GITHUB_USER_TOKEN:
description: Authentication token with write permission needed by the release bot (falls back to GITHUB_TOKEN).
description: Authentication token with write permission needed by the release bot (falls back to `GITHUB_TOKEN`).
required: false

jobs:
Expand All @@ -13,6 +34,9 @@ jobs:
runs-on: ubuntu-latest
env:
HAS_CONFIG: false
NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }}
GITHUB_USER_SSH_KEY: ${{ secrets.GITHUB_USER_SSH_KEY }}
GITHUB_USER_SSH_PUBLIC_KEY: ${{ secrets.GITHUB_USER_SSH_PUBLIC_KEY }}
steps:
- name: Fetch semantic-release Node version
uses: actions/checkout@v4
Expand All @@ -23,23 +47,43 @@ jobs:
sparse-checkout-cone-mode: false
path: semantic-release-repo

- name: Setup Node.js
- name: Set up node
uses: actions/setup-node@v4
with:
node-version-file: semantic-release-repo/package.json
registry-url: ${{ inputs.NPM_REGISTRY_DOMAIN }}

- name: Install dependencies
run: |
npm i -g @semantic-release/changelog \
@semantic-release/git \
@semantic-release/npm \
@semantic-release/exec \
semantic-release
semantic-release \
conventional-changelog-conventionalcommits
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
ssh-key: ${{ env.GITHUB_USER_SSH_KEY }}

- name: Set up SSH
if: ${{ env.GITHUB_USER_SSH_KEY != '' }}
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ env.GITHUB_USER_SSH_KEY }}

- name: Set up signing commits
if: ${{ env.GITHUB_USER_SSH_PUBLIC_KEY != '' }}
run: |
: # Create empty SSH private key file so Git does not complain.
touch "${{ runner.temp }}/signingkey"
echo "${{ env.GITHUB_USER_SSH_PUBLIC_KEY }}" > "${{ runner.temp }}/signingkey.pub"
git config --global commit.gpgsign true
git config --global gpg.format ssh
git config --global user.signingkey "${{ runner.temp }}/signingkey.pub"
- name: Check presence of release.config.js
run: |
Expand All @@ -66,7 +110,23 @@ jobs:
run: |
rm -rf workflow-repo
- name: Set up release environment variables
env:
GITHUB_USER_EMAIL: ${{ secrets.GITHUB_USER_EMAIL }}
GITHUB_USER_NAME: ${{ secrets.GITHUB_USER_NAME }}
run: |
${{ env.GITHUB_USER_EMAIL != '' }} && echo "GIT_AUTHOR_EMAIL=${{ env.GITHUB_USER_EMAIL }}" >> $GITHUB_ENV || true
${{ env.GITHUB_USER_NAME != '' }} && echo "GIT_AUTHOR_NAME=${{ env.GITHUB_USER_NAME }}" >> $GITHUB_ENV || true
${{ env.GITHUB_USER_EMAIL != '' }} && echo "GIT_COMMITTER_EMAIL=${{ env.GITHUB_USER_EMAIL }}" >> $GITHUB_ENV || true
${{ env.GITHUB_USER_NAME != '' }} && echo "GIT_COMMITTER_NAME=${{ env.GITHUB_USER_NAME }}" >> $GITHUB_ENV || true
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_USER_TOKEN != '' && secrets.GITHUB_USER_TOKEN || secrets.GITHUB_TOKEN }}
run: npx semantic-release

- name: Delete signing key files
if: ${{ always() && env.GITHUB_USER_SSH_PUBLIC_KEY != '' }}
run: |
rm -f "${{ runner.temp }}/signingkey"
rm -f "${{ runner.temp }}/signingkey.pub"
50 changes: 38 additions & 12 deletions .github/workflows/build-and-push-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,17 @@ on:
required: false
type: string
ASSETS_TARGET_PATHS:
description: Target path(s) for compiled assets.
description: Space-separated list of target directory paths for compiled assets.
default: './assets'
required: false
type: string
BUILT_BRANCH_SUFFIX:
description: Suffix to calculate the target branch for pushing assets on the `branch` event.
ASSETS_TARGET_FILES:
description: Space-separated list of target file paths for compiled assets.
default: ''
required: false
type: string
BUILT_BRANCH_NAME:
description: Sets the target branch for pushing assets on the `branch` event.
type: string
default: ''
required: false
Expand Down Expand Up @@ -81,6 +86,9 @@ on:
GITHUB_USER_SSH_KEY:
description: Private SSH key associated with the GitHub user passed as `GITHUB_USER_NAME`.
required: false
GITHUB_USER_SSH_PUBLIC_KEY:
description: Public SSH key associated with the GitHub user passed as `GITHUB_USER_NAME`.
required: false
ENV_VARS:
description: Additional environment variables as a JSON formatted object.
required: false
Expand Down Expand Up @@ -132,10 +140,10 @@ jobs:
GITHUB_USER_EMAIL: ${{ secrets.GITHUB_USER_EMAIL }}
GITHUB_USER_NAME: ${{ secrets.GITHUB_USER_NAME }}
GITHUB_USER_SSH_KEY: ${{ secrets.GITHUB_USER_SSH_KEY }}
GITHUB_USER_SSH_PUBLIC_KEY: ${{ secrets.GITHUB_USER_SSH_PUBLIC_KEY }}
COMPILE_SCRIPT: ''
TAG_NAME: '' # we'll override if the push is for tag
TAG_BRANCH_NAME: '' # we'll override if the push is for tag
LOCK_FILE: '' # we'll override after checking files
NO_CHANGES: '' # we'll override if no changes to commit
steps:
- name: Checkout
Expand All @@ -157,6 +165,16 @@ jobs:
git config --global advice.addIgnoredFile false
git config --global push.autoSetupRemote true
- name: Set up signing commits
if: ${{ env.GITHUB_USER_SSH_PUBLIC_KEY != '' }}
run: |
: # Create empty SSH private key file so Git does not complain.
touch "${{ runner.temp }}/signingkey"
echo "${{ env.GITHUB_USER_SSH_PUBLIC_KEY }}" > "${{ runner.temp }}/signingkey.pub"
git config --global commit.gpgsign true
git config --global gpg.format ssh
git config --global user.signingkey "${{ runner.temp }}/signingkey.pub"
- name: Set up custom environment variables
env:
ENV_VARS: ${{ secrets.ENV_VARS }}
Expand All @@ -183,7 +201,7 @@ jobs:
- name: Set branch environment variables
if: ${{ github.ref_type == 'branch' }}
run: |
echo "BUILT_BRANCH_NAME=${{ github.ref_name }}${{ inputs.BUILT_BRANCH_SUFFIX }}" >> $GITHUB_ENV
echo "BUILT_BRANCH_NAME=${{ inputs.BUILT_BRANCH_NAME && inputs.BUILT_BRANCH_NAME || github.ref_name }}" >> $GITHUB_ENV
- name: Set tag environment variables
if: ${{ github.ref_type == 'tag' }}
Expand All @@ -194,18 +212,18 @@ jobs:
- name: Checkout and merge the built branch
if: ${{ github.ref_type == 'branch' }}
run: |
git checkout ${{ env.BUILT_BRANCH_NAME }} || git checkout -b ${{ env.BUILT_BRANCH_NAME }}
git show-ref -q refs/remotes/origin/${{ env.BUILT_BRANCH_NAME }} && git checkout ${{ env.BUILT_BRANCH_NAME }} || git checkout -b ${{ env.BUILT_BRANCH_NAME }}
git merge ${{ github.ref_name }}
- name: Git pull on re-run
if: ${{ (github.run_attempt > 1) && (github.ref_type != 'tag') }}
run: git pull
run: git show-ref -q refs/remotes/origin/$(git branch --show-current) && git pull || true

- name: Checkout and merge the release branch
if: ${{ github.ref_type == 'tag' && env.RELEASE_BRANCH_ENABLED == 'yes' }}
run: |
git checkout ${{ github.event.repository.default_branch }}
git checkout ${{ inputs.RELEASE_BRANCH_NAME }} || git checkout -b ${{ inputs.RELEASE_BRANCH_NAME }}
git show-ref -q refs/remotes/origin/${{ inputs.RELEASE_BRANCH_NAME }} && git checkout ${{ inputs.RELEASE_BRANCH_NAME }} || git checkout -b ${{ inputs.RELEASE_BRANCH_NAME }}
git merge ${{ github.event.repository.default_branch }}
- name: Checkout temporary tag branch
Expand Down Expand Up @@ -253,13 +271,15 @@ jobs:

- name: Git add, commit
run: |
declare -a TARGET_PATHS_ARRAY=(${{ inputs.ASSETS_TARGET_PATHS }})
for path in "${TARGET_PATHS_ARRAY[@]}"; do git add -f "${path}/*"; done
declare -a TARGET_DIRECTORY_PATHS_ARRAY=(${{ inputs.ASSETS_TARGET_PATHS }})
for path in "${TARGET_DIRECTORY_PATHS_ARRAY[@]}"; do git add -f "${path}/*"; done
declare -a TARGET_FILES_PATHS_ARRAY=(${{ inputs.ASSETS_TARGET_FILES }})
for path in "${TARGET_FILES_PATHS_ARRAY[@]}"; do [[ -f "$path" ]] && git add -f "${path}"; done
git add -A
git commit -m "[BOT] Add compiled assets for #${{ github.ref }}" --no-verify || ((echo "NO_CHANGES=yes" >> $GITHUB_ENV) && (echo "No changes to commit"))
- name: Git push for branch
if: ${{ github.ref_type == 'branch' && (env.NO_CHANGES != 'yes' || inputs.BUILT_BRANCH_SUFFIX != '') }}
if: ${{ github.ref_type == 'branch' }}
run: git push

- name: Git push for tag
Expand All @@ -275,8 +295,14 @@ jobs:
git push origin --tags
- name: Delete temporary tag branch
if: ${{ always() && (env.TAG_BRANCH_NAME != '' && env.NO_CHANGES != 'yes') }}
if: ${{ always() && env.TAG_BRANCH_NAME != '' && env.NO_CHANGES != 'yes' }}
run: |
git checkout --detach
git branch -d ${{ env.TAG_BRANCH_NAME }}
git push origin --delete ${{ env.TAG_BRANCH_NAME }}
- name: Delete signing key files
if: ${{ always() && env.GITHUB_USER_SSH_PUBLIC_KEY != '' }}
run: |
rm -f "${{ runner.temp }}/signingkey"
rm -f "${{ runner.temp }}/signingkey.pub"
Loading

0 comments on commit 2d69b4c

Please sign in to comment.