Skip to content

Commit

Permalink
update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
eq19 committed Nov 19, 2024
1 parent ff35858 commit 61950e8
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 40 deletions.
12 changes: 8 additions & 4 deletions .github/actions/1-addition/2-feed/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,18 @@ runs:
OWNER: ${{ github.repository_owner }}
BEARER: ${{ steps.auth.outputs.id_token }}
run: |
shopt -s dotglob
rm -rf ${{ inputs.action_path }}/.git
mv -f ${{ inputs.action_path }}/_config.yml ${RUNNER_TEMP}/
mv -f ${{ inputs.action_path }}/_config.yml ${RUNNER_TEMP}/
export PATH=$GITHUB_WORKSPACE/.github/entrypoint:$PATH && artifact.sh
shopt -s dotglob && mv -f ${RUNNER_TEMP}/workdir/* ${{ inputs.action_path }}/
mv -f ${RUNNER_TEMP}/.env ${{ inputs.action_path }}/
mv -f ${RUNNER_TEMP}/_config.yml ${{ inputs.action_path }}/
#mkdir -p ${{ github.workspace }}/_site
#cp -R ${{ inputs.action_path }}/. ${{ github.workspace }}/_site/
mkdir -p ${{ inputs.action_path }}/_data
mv -f ${RUNNER_TEMP}/*.json ${{ inputs.action_path }}/_data/

mv ${{ inputs.action_path }} ${{ github.workspace }}/_site
mkdir -p ${{ inputs.action_path }} && cp -R ${{ github.workspace }}/_site/. ${{ inputs.action_path }}/

Expand Down
2 changes: 1 addition & 1 deletion .github/actions/3-exponentiation/4-parser/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ runs:
run: |
if [ -d /mnt/disks/platform/usr/local/sbin ]; then
export PAULI_SUM=$(echo -n "${{ inputs.pauli_sum }}" | base64 --decode);
${{ inputs.action_path }}/.github/entrypoint/init.sh
export PATH=/home/runner/_work/_actions/eq19/eq19/v1/.github/entrypoint:$PATH && init.sh
else
exit 1
fi
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/4-identition/4-parser/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ runs:
shell: bash
env:
BASE: "D:/a/_actions/eq19/eq19/v1/.github"
TOKEN: ${{ steps.auth.outputs.id_token }}
GCP_TOKEN: ${{ steps.auth.outputs.id_token }}
run: |
curl -s -X POST https://us-central1-feedmapping.cloudfunctions.net/function \
-H "Authorization: Bearer ${TOKEN}" -H "Content-Type: application/json" \
-H "Authorization: Bearer ${GCP_TOKEN}" -H "Content-Type: application/json" \
--data @${{ inputs.workspace }}/docs/data.json | jq '.'
$BASE/entrypoint/init.sh
Expand Down
23 changes: 5 additions & 18 deletions .github/entrypoint/artifact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,30 +97,17 @@ jekyll_build() {
sed -i "1s|^|repository: ${OWNER}/$1\n|" ${RUNNER_TEMP}/_config.yml
[[ $1 != *"github.io"* ]] && sed -i "1s|^|baseurl: /$1\n|" ${RUNNER_TEMP}/_config.yml

FOLDER="span$(( 17 - $3 ))"
echo 'FOLDER='${FOLDER} >> ${RUNNER_TEMP}/.env

sed -i "1s|^|title: eQuantum\n|" ${RUNNER_TEMP}/_config.yml
FOLDER="span$(( 17 - $3 ))" && sed -i "1s|^|span: ${FOLDER}\n|" ${RUNNER_TEMP}/_config.yml
sed -i "1s|^|span: ${FOLDER}\n|" ${RUNNER_TEMP}/_config.yml
sed -i "1s|^|user: ${USER}\n|" ${RUNNER_TEMP}/_config.yml

sed -i "1s|^|id: ${SITEID}\n|" ${RUNNER_TEMP}/_config.yml

echo 'ID='${SITEID} >> ${GITHUB_ENV}
cat ${RUNNER_TEMP}/_config.yml

echo -e "\n$hr\nWORKSPACE\n$hr"
gist.sh $1 ${OWNER} ${FOLDER}
find ${RUNNER_TEMP}/gistdir -type d -name .git -prune -exec rm -rf {} \;

cd ${RUNNER_TEMP}/workdir && mv -f ${RUNNER_TEMP}/_config.yml .
rm -rf ${RUNNER_TEMP}/Sidebar.md && cp _Sidebar.md ${RUNNER_TEMP}/Sidebar.md
sed -i 's/0. \[\[//g' ${RUNNER_TEMP}/Sidebar.md && sed -i 's/\]\]//g' ${RUNNER_TEMP}/Sidebar.md

echo -e "\n$hr\nSPIN\n$hr"
find . -iname '*.md' -print0 | sort -zn | xargs -0 -I '{}' front.sh '{}'
find . -type d -name "${FOLDER}" -prune -exec sh -c 'cat ${RUNNER_TEMP}/README.md >> $1/README.md' sh {} \;

cp -R ${RUNNER_TEMP}/gistdir/* . && mkdir ${RUNNER_TEMP}/workdir/_data
#echo 'orgs_json='$(cat ${RUNNER_TEMP}/orgs.json) >> ${GITHUB_OUTPUT}
mv -f ${RUNNER_TEMP}/*.json ${RUNNER_TEMP}/workdir/_data/

}

# Get structure on gist files
Expand Down
5 changes: 2 additions & 3 deletions .github/entrypoint/gist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

rm -rf ${RUNNER_TEMP}/*dir

WIKI=https://github.com/$2/$1.wiki.git
WIKI=https://github.com/$1.wiki.git
BASE=https://github.com/eq19/eq19.github.io.wiki.git

#git ls-remote ${WIKI} > /dev/null 2>&1
Expand Down Expand Up @@ -41,6 +41,5 @@ find ${RUNNER_TEMP}/gistdir -type f -name 'spin_*.txt' | sort -n -t _ -k 2 | wh
if [[ "${WIKI}" != "${BASE}" ]]; then
git clone $WIKI ${RUNNER_TEMP}/wikidir
mv -f ${RUNNER_TEMP}/wikidir/Home.md ${RUNNER_TEMP}/wikidir/README.md
echo $3
find ${RUNNER_TEMP}/gistdir -type d -name "$3" -prune -exec sh -c 'wiki.sh "$1"' sh {} \;
find ${RUNNER_TEMP}/gistdir -type d -name "$2" -prune -exec sh -c 'wiki.sh "$1"' sh {} \;
fi
43 changes: 31 additions & 12 deletions .github/entrypoint/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"

git config --global --add safe.directory "${GITHUB_WORKSPACE}"
#[[ "$RUNNER_OS" == "Windows" ]] && git config --global core.autocrlf true
[[ "$RUNNER_OS" == "Windows" ]] && YQ=$(choco install yq)
[[ "$RUNNER_OS" == "Windows" ]] && git config --global core.safecrlf false

git config --global credential.helper store
Expand All @@ -19,20 +19,14 @@ REMOTE_REPO="https://${GITHUB_ACTOR}:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}

API_URL="https://api.github.com/users/eq19/events/public"
LATEST_COMMIT=$(curl -s $API_URL | jq ".[0].payload.commits[0].message")
if [[ $? -eq 0 ]]; then
if [[ -z "$LATEST_COMMIT" ]]; then
echo 'LATEST_COMMIT="update by workspace"' >> ${GITHUB_ENV}
elif [[ "$LATEST_COMMIT" == null ]]; then
echo 'LATEST_COMMIT="update by workspace"' >> ${GITHUB_ENV}
else
echo 'LATEST_COMMIT='$LATEST_COMMIT >> ${GITHUB_ENV}
fi
else
if [[ -z "$LATEST_COMMIT" ]] || [[ "$LATEST_COMMIT" == "null" ]]; then
echo 'LATEST_COMMIT="update by workspace"' >> ${GITHUB_ENV}
else
echo 'LATEST_COMMIT='$LATEST_COMMIT >> ${GITHUB_ENV}
fi

if [[ "${JOB_ID}" == "1" ]]; then

cd "${GITHUB_WORKSPACE}" && rm -rf .github
cp -r /home/runner/work/_actions/eq19/eq19/v1/.github .
chown -R "$(whoami)" .github
Expand All @@ -48,8 +42,33 @@ if [[ -z ${PASS} ]] || [[ "${PASS}" == "true" ]]; then
echo -e "\n$hr\nENVIRONTMENT\n$hr"
echo 'TARGET_REPO='${TARGET_REPO} >> ${GITHUB_ENV}
echo 'REMOTE_REPO='${REMOTE_REPO} >> ${GITHUB_ENV}

if [[ -f _config.yml ]]; then
FOLDER=$(yq '.span' _config.yml)
export FOLDER=$(eval echo $FOLDER)
elif [[ -f /home/runner/_site/.env ]]; then
set -a && . /home/runner/_site/.env && set +a
fi
printenv | sort

echo -e "\n$hr\nGITHUB CONTEXT\n$hr"
fi

if [[ "${JOB_ID}" == "3" ]]; then

echo -e "\n$hr\nWORKSPACE\n$hr"
gist.sh ${TARGET_REPOSITORY} ${FOLDER}
find ${RUNNER_TEMP}/gistdir -type d -name .git -prune -exec rm -rf {} \;

mv -f ${RUNNER_TEMP}/workdir/* /home/runner/_site/
rm -rf ${RUNNER_TEMP}/Sidebar.md && cp _Sidebar.md ${RUNNER_TEMP}/Sidebar.md
sed -i 's/0. \[\[//g' ${RUNNER_TEMP}/Sidebar.md && sed -i 's/\]\]//g' ${RUNNER_TEMP}/Sidebar.md

cd /home/runner/_site && cp -R ${RUNNER_TEMP}/gistdir/* .
find . -iname '*.md' -print0 | sort -zn | xargs -0 -I '{}' front.sh '{}'
find . -type d -name "${FOLDER}" -prune -exec sh -c 'cat ${RUNNER_TEMP}/README.md >> $1/README.md' sh {} \;

fi

if [[ -z ${PASS} ]] || [[ "${PASS}" == "true" ]]; then
echo -e "\n$hr\nGITHUB CONTEXT\n$hr"
fi
4 changes: 4 additions & 0 deletions .github/entrypoint/wiki.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

hr='------------------------------------------------------------------------------------'

gh gist clone 0ce5848f7ad62dc46dedfaa430069857 $1/identition/span1
gh gist clone b32915925d9d365e2e9351f0c4ed786e $1/identition/span2
gh gist clone 88d09204b2e5986237bd66d062406fde $1/identition/span3
Expand Down Expand Up @@ -30,4 +32,6 @@ rm -rf ${RUNNER_TEMP}/Sidebar.md && cp $1/_Sidebar.md ${RUNNER_TEMP}/Sidebar.md
sed -i 's/0. \[\[//g' ${RUNNER_TEMP}/Sidebar.md && sed -i 's/\]\]//g' ${RUNNER_TEMP}/Sidebar.md

find $1 -iname '*.md' -print0 | sort -zn | xargs -0 -I '{}' front.sh '{}'

echo -e "\n$hr\nSPIN\n$hr"
cat ${RUNNER_TEMP}/spin.txt

0 comments on commit 61950e8

Please sign in to comment.