Skip to content

Post authenticated login in Login.authenticate.successful for token-only auth #16511

Post authenticated login in Login.authenticate.successful for token-only auth

Post authenticated login in Login.authenticate.successful for token-only auth #16511

Workflow file for this run

name: Build woff2 font file
on:
pull_request:
types: [synchronize, opened]
permissions:
actions: read
checks: none
contents: write
deployments: none
issues: write
packages: none
pull-requests: write
repository-projects: none
security-events: none
statuses: none
jobs:
build:
runs-on: ubuntu-24.04
name: build woff2
steps:
- name: Detect branch for PR
id: vars
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR="${{ github.event.pull_request.number }}"
PR_INFO=$( curl \
--request GET \
--header "authorization: Bearer ${GITHUB_TOKEN}" \
--header 'content-type: application/json' \
--url "https://api.github.com/repos/$GITHUB_REPOSITORY/pulls/$PR" )
REF=$(echo "${PR_INFO}" | jq -r .head.ref)
BASE=$(echo "${PR_INFO}" | jq -r .head.repo.full_name)
STATE=$(echo "${PR_INFO}" | jq -r .state)
BASE_SHA=$(echo "${PR_INFO}" | jq -r .base.sha)
if [[ $STATE == "closed" ]]
then
echo "Pull Request already closed."
exit 0;
fi
if [[ "$BASE" == "$GITHUB_REPOSITORY" ]]
then
echo "islocalbranch=1" >> "$GITHUB_OUTPUT"
else
echo "islocalbranch=0" >> "$GITHUB_OUTPUT"
fi
echo "branch=$REF" >> "$GITHUB_OUTPUT"
echo "base=$BASE_SHA" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v7
with:
lfs: false
persist-credentials: false
if: steps.vars.outputs.branch != ''
- name: Check ttf changes
id: ttfcheck
run: |
git fetch --depth=1 origin "$BASE_SHA"
TTF_FILE_MODIFIED=$(git diff --name-only "$BASE_SHA" -- plugins/Morpheus/fonts/matomo.ttf | wc -l)
if [[ $TTF_FILE_MODIFIED == "0" ]]
then
echo "Font file not modified"
exit 0;
fi
echo "ttf_modified=1" >> "$GITHUB_OUTPUT"
env:
BASE_SHA: ${{ steps.vars.outputs.base }}
if: steps.vars.outputs.branch != ''
- name: Build woff2 file
run: |
git clone --recursive https://github.com/google/woff2.git tmp_woff2
cd tmp_woff2
make clean all
cd ..
./tmp_woff2/woff2_compress plugins/Morpheus/fonts/matomo.ttf
if: steps.vars.outputs.branch != '' && steps.ttfcheck.outputs.ttf_modified == '1'
- name: Prepare git config
run: |
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
git config --global user.name "$GITHUB_ACTOR"
if [[ "$IS_LOCAL_BRANCH" == "1" ]]
then
git fetch --depth=1 origin "$BRANCH_NAME"
git checkout "$BRANCH_NAME"
fi
env:
BRANCH_NAME: ${{ steps.vars.outputs.branch }}
IS_LOCAL_BRANCH: ${{ steps.vars.outputs.islocalbranch }}
if: steps.vars.outputs.branch != '' && steps.ttfcheck.outputs.ttf_modified == '1'
- name: Push changes
id: push
run: |
if [[ $( git diff --numstat plugins/Morpheus/fonts/matomo.woff2 ) ]]
then
if [[ "$IS_LOCAL_BRANCH" != "1" ]]
then
echo "It's only possible to update local branches automatically. Adding a comment instead."
echo "failure=1" >> "$GITHUB_OUTPUT"
else
cd "$GITHUB_WORKSPACE"
git add plugins/Morpheus/fonts/matomo.woff2
git commit -m "Build woff2 file"
git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}" "HEAD:${BRANCH_NAME}"
fi
fi
env:
BRANCH_NAME: ${{ steps.vars.outputs.branch }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IS_LOCAL_BRANCH: ${{ steps.vars.outputs.islocalbranch }}
if: steps.vars.outputs.branch != '' && steps.ttfcheck.outputs.ttf_modified == '1'
- uses: actions/github-script@v9
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'woff2 font file is not up to date. See https://developer.matomo.org/guides/matomo-font for details how to update the font correctly.'
})
if: steps.push.outputs.failure == '1'
- name: Fail if not up to date
run: exit 1
if: steps.push.outputs.failure == '1'