Skip to content

Commit c4b3a6e

Browse files
committed
update workflows
1 parent b587350 commit c4b3a6e

File tree

6 files changed

+82
-108
lines changed

6 files changed

+82
-108
lines changed

.github/actions/1-addition/1-maps/action.yml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ runs:
9595
steps:
9696
- name: Remove Existing Connection
9797
shell: bash
98+
env:
99+
RUN: ${{ github.run_id }}
100+
USER: ${{ github.actor }}
101+
REPO: ${{ github.repository }}
102+
ACTOR: ${{ github.triggering_actor }}
103+
OWNER: ${{ github.repository_owner }}
98104
run: |
99105
gh variable set RERUN_RUNNER --body "false"
100106
@@ -121,12 +127,6 @@ runs:
121127
with:
122128
script: console.log(context)
123129

124-
- name: Login to DockerHub
125-
uses: docker/login-action@v3
126-
with:
127-
username: ${{ inputs.hub_username }}
128-
password: ${{ inputs.hub_token }}
129-
130130
#- uses: actions/setup-python@v5
131131
#with:
132132
#python-version: 3.12
@@ -140,25 +140,27 @@ runs:
140140
- name: Install dependencies
141141
shell: bash
142142
env:
143-
RUN: ${{ github.run_id }}
144-
USER: ${{ github.actor }}
145-
REPO: ${{ github.repository }}
146143
ACCESS_API: ${{ inputs.api_key }}
147144
ACCESS_KEY: ${{ inputs.api_secret }}
148145
ACCESS_TOKEN: ${{ inputs.token }}
149146
MESSAGE_API: ${{ inputs.chat_id }}
150147
MONITOR_TOKEN: ${{ inputs.bot_token }}
151148
WARNING_TOKEN: ${{ inputs.logs_token }}
152149
PYPI_TOKEN: ${{ inputs.pypi_token }}
153-
ACTOR: ${{ github.triggering_actor }}
154-
OWNER: ${{ github.repository_owner }}
155150
DOCKER_HUB_TOKEN: ${{ inputs.hub_token }}
156151
DOCKER_HUB_PASSWORD: ${{ inputs.hub_password }}
157152
GCP_CREDENTIALS: ${{ inputs.credentials }}
158153
run: |
159-
mv -f .github/templates/jekyll_config.yml ${{ runner.temp }}/_config.yml
160-
export PATH=.github/entrypoint:$PATH && artifact.sh
161-
154+
echo "🔄 Syncing secrets from ${{ github.repository }} to ${{ env.TARGET_REPOSITORY }}"
155+
156+
# Get all secrets from source repository
157+
secrets=$(curl -s -H "Authorization: token $GH_TOKEN" -H "Accept: application/vnd.github.v3+json" \
158+
"https://api.github.com/repos/${{ github.repository }}/actions/secrets" | jq -r '.secrets[].name')
159+
160+
for secret in $secrets; do
161+
gh secret set $secret --repo ${{ env.TARGET_REPOSITORY }} --body "${!secret}"
162+
done
163+
162164
#python -m pip -q install --upgrade pip
163165
#python -m pip -q install -r ${{ inputs.action_path }}/dataFile/requirements.txt
164166

@@ -175,6 +177,12 @@ runs:
175177
##python ${{ github.workspace }}/.github/entrypoint/artifact/python/gellmann.py
176178
##cd ${{ inputs.action_path }}/pythonCode && python npreader.py -h && python map.py -h
177179

180+
- name: Login to DockerHub
181+
uses: docker/login-action@v3
182+
with:
183+
username: ${{ inputs.hub_username }}
184+
password: ${{ inputs.hub_token }}
185+
178186
- name: 🚀 Initiate Lexer
179187
uses: devcontainers/[email protected]
180188
with:

.github/entrypoint/artifact.sh

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,27 +107,22 @@ jekyll_build() {
107107
sed -i "1s|^|id: ${SITEID}\n|" ${RUNNER_TEMP}/_config.yml
108108

109109
echo 'ID='${SITEID} >> ${GITHUB_ENV}
110-
111-
echo -e "\n$hr\nCONFIG\n$hr"
112110
cat ${RUNNER_TEMP}/_config.yml
113111

114112
if [[ "${TARGET_REPOSITORY}" != *"eq19/"* ]]; then
115113

116114
echo -e "\nTest Module Structure:"
117-
echo "1. Chetabahana/maps → $(next_repo "Chetabahana/maps")"
118-
echo "2. Chetabahana/grammar → $(next_repo "Chetabahana/grammar")"
119-
echo "3. Chetabahana/track$(next_repo "Chetabahana/track")"
120-
echo "4. FeedMapping/FeedMapping.github.io → $(next_repo "FeedMapping/FeedMapping.github.io")"
121-
echo "5. ${TARGET_REPOSITORY}$(next_repo "${TARGET_REPOSITORY}")"
115+
echo "1. ${OWNER}/maps → $(next_repo "${OWNER}/maps")"
116+
echo "2. ${OWNER}/grammar → $(next_repo "${OWNER}/grammar")"
117+
NEXT_REPOSITORY=$(next_repo "${OWNER}/$(yq -r '.track.pinned | .[-1]' ${RUNNER_TEMP}/_config.yml)")
118+
echo "3. ${OWNER}/$(yq -r '.track.pinned | .[-1]' ${RUNNER_TEMP}/_config.yml)${NEXT_REPOSITORY}"
119+
echo "4. ${NEXT_REPOSITORY}$(next_repo "${NEXT_REPOSITORY}")"
122120

123121
NEXT_REPOSITORY=$(next_repo "${TARGET_REPOSITORY}")
124122
gh variable set TARGET_REPOSITORY --repo $TARGET_REPOSITORY --body "$NEXT_REPOSITORY"
125123

126124
fi
127125

128-
echo -e "\n$hr\nSET TOKEN\n$hr"
129-
sync.sh ${REPO} ${TARGET_REPOSITORY} ${GH_TOKEN}
130-
131126
# Fetch SHA, encode new content, and update in one step
132127
gh api --method PUT /repos/${TARGET_REPOSITORY}/contents/.github/workflows/main.yml \
133128
-f sha="$(gh api /repos/${TARGET_REPOSITORY}/contents/.github/workflows/main.yml --jq '.sha')" \

.github/entrypoint/init.sh

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ fi
3939

4040
if [[ -z ${PASS} ]] || [[ "${PASS}" == "true" ]]; then
4141

42-
echo -e "\n$hr\nENVIRONTMENT\n$hr"
4342
echo 'TARGET_REPO='${TARGET_REPO} >> ${GITHUB_ENV}
4443
echo 'REMOTE_REPO='${REMOTE_REPO} >> ${GITHUB_ENV}
4544

@@ -50,6 +49,23 @@ if [[ -z ${PASS} ]] || [[ "${PASS}" == "true" ]]; then
5049
elif [[ -f /home/runner/_site/.env ]]; then
5150
set -a && . /home/runner/_site/.env && set +a
5251
fi
52+
53+
if [[ -d $1/user_data/strategies ]]; then
54+
echo -e "\n$hr\nCONFIG\n$hr"
55+
mv -f /home/runner/work/_actions/eq19/eq19/v2/.github/templates/jekyll_config.yml $RUNNER_TEMP/_config.yml
56+
export PATH=/home/runner/work/_actions/eq19/eq19/v2/.github/entrypoint:$PATH && artifact.sh
57+
58+
PARAMS_JSON=$(curl -s -H "Authorization: token $GH_TOKEN" -H "Accept: application/vnd.github.v3+json" \
59+
"https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/variables/PARAMS_JSON" | jq -r '.value')
60+
echo "${PARAMS_JSON}" | jq '.' > $1/user_data/strategies/fibbo.json
61+
if jq empty < $1/user_data/strategies/fibbo.json; then
62+
echo -e "\n$hr\nPARAMETERS\n$hr"
63+
cat $1/user_data/strategies/fibbo.json
64+
else
65+
echo "Invalid JSON"
66+
fi
67+
fi
68+
echo -e "\n$hr\nENVIRONTMENT\n$hr"
5369
printenv | sort
5470

5571
fi
@@ -77,19 +93,8 @@ if [[ "${JOBS_ID}" == "1" ]]; then
7793

7894
else
7995

80-
PARAMS_JSON=$(curl -s -H "Authorization: token $GH_TOKEN" -H "Accept: application/vnd.github.v3+json" \
81-
"https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/variables/PARAMS_JSON" | jq -r '.value')
82-
echo "${PARAMS_JSON}" | jq '.' > $1/user_data/strategies/fibbo.json
83-
8496
cd $1 && javac -d user_data/ft_client/test_client javaCode/Main.java
85-
if jq empty < user_data/strategies/fibbo.json; then
86-
cat user_data/strategies/fibbo.json
87-
else
88-
echo "Invalid JSON"
89-
fi
90-
91-
cd $GITHUB_WORKSPACE
92-
rm -rf user_data && mv -f $1/user_data . && ls -al .
97+
cd $GITHUB_WORKSPACE && rm -rf user_data && mv -f $1/user_data . && ls -al .
9398

9499
fi
95100

.github/entrypoint/sync.sh

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
#!/bin/bash
22

3-
# GitHub Personal Access Token (PAT) - Store securely
4-
GITHUB_PAT="$3"
5-
63
# GitHub API Base URL
74
GITHUB_API="https://api.github.com"
85

96
# Function to check if a secret exists in a repository
107
check_secret_exists() {
118
local repo=$1
129
local secret_name=$2
13-
curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token $GITHUB_PAT" \
10+
curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token $GH_TOKEN" \
1411
-H "Accept: application/vnd.github.v3+json" "$GITHUB_API/repos/$repo/actions/secrets/$secret_name"
1512
}
1613

@@ -28,7 +25,7 @@ set_secret() {
2825
check_variable_exists() {
2926
local repo=$1
3027
local var_name=$2
31-
response=$(curl -s -H "Authorization: token $GITHUB_PAT" \
28+
response=$(curl -s -H "Authorization: token $GH_TOKEN" \
3229
-H "Accept: application/vnd.github.v3+json" "$GITHUB_API/repos/$repo/actions/variables")
3330

3431
echo "$response" | jq -e ".variables[] | select(.name == \"$var_name\")" > /dev/null 2>&1
@@ -53,41 +50,45 @@ sync_secrets_and_variables() {
5350
echo "🔄 Syncing secrets from $source_repo to $target_repo..."
5451

5552
# Get all secrets from source repository
56-
secrets=$(curl -s -H "Authorization: token $GITHUB_PAT" \
53+
secrets=$(curl -s -H "Authorization: token $GH_TOKEN" \
5754
-H "Accept: application/vnd.github.v3+json" "$GITHUB_API/repos/$source_repo/actions/secrets" | jq -r '.secrets[].name')
5855

5956
for secret in $secrets; do
60-
if [[ "$(check_secret_exists "$target_repo" "$secret")" == "404" ]]; then
61-
echo "➕ Secret '$secret' does not exist in $target_repo. Copying..."
62-
set_secret "$target_repo" "$secret" "${!secret}"
63-
else
64-
echo "✅ Secret '$secret' already exists in $target_repo."
65-
fi
57+
set_secret "$target_repo" "$secret" "${!secret}"
58+
#if [[ "$(check_secret_exists "$target_repo" "$secret")" == "404" ]]; then
59+
#echo "➕ Secret '$secret' does not exist in $target_repo. Copying..."
60+
#set_secret "$target_repo" "$secret" "${!secret}"
61+
#else
62+
#echo "✅ Secret '$secret' already exists in $target_repo."
63+
#fi
6664
done
6765

68-
echo "🔄 Syncing variables from $source_repo to $target_repo..."
66+
#echo "🔄 Syncing variables from $source_repo to $target_repo..."
6967

7068
# Get all variables from source repository
71-
variables=$(curl -s -H "Authorization: token $GITHUB_PAT" \
72-
-H "Accept: application/vnd.github.v3+json" "$GITHUB_API/repos/$source_repo/actions/variables" | jq -r '.variables[].name')
73-
74-
for var in $variables; do
75-
if ! check_variable_exists "$target_repo" "$var"; then
76-
echo "➕ Variable '$var' does not exist in $target_repo. Copying..."
77-
var_value=$(curl -s -H "Authorization: token $GITHUB_PAT" \
78-
-H "Accept: application/vnd.github.v3+json" "$GITHUB_API/repos/$source_repo/actions/variables/$var" | jq -r '.value')
79-
set_variable "$target_repo" "$var" "$var_value"
80-
else
81-
echo "✅ Variable '$var' already exists in $target_repo."
82-
fi
83-
done
69+
#variables=$(curl -s -H "Authorization: token $GH_TOKEN" \
70+
#-H "Accept: application/vnd.github.v3+json" "$GITHUB_API/repos/$source_repo/actions/variables" | jq -r '.variables[].name')
71+
72+
#for var in $variables; do
73+
#var_value=$(curl -s -H "Authorization: token $GH_TOKEN" \
74+
#-H "Accept: application/vnd.github.v3+json" "$GITHUB_API/repos/$source_repo/actions/variables/$var" | jq -r '.value')
75+
#set_variable "$target_repo" "$var" "$var_value"
76+
#if ! check_variable_exists "$target_repo" "$var"; then
77+
#echo "➕ Variable '$var' does not exist in $target_repo. Copying..."
78+
#var_value=$(curl -s -H "Authorization: token $GH_TOKEN" \
79+
#-H "Accept: application/vnd.github.v3+json" "$GITHUB_API/repos/$source_repo/actions/variables/$var" | jq -r '.value')
80+
#set_variable "$target_repo" "$var" "$var_value"
81+
#else
82+
#echo "✅ Variable '$var' already exists in $target_repo."
83+
#fi
84+
#done
8485

8586
echo "✅ Sync complete!"
8687
}
8788

8889
# Check for required arguments
89-
if [[ $# -ne 3 ]]; then
90-
echo "Usage: $0 <source_repo> <target_repo> <github_pat>"
90+
if [[ $# -ne 2 ]]; then
91+
echo "Usage: $0 <source_repo> <target_repo>"
9192
exit 1
9293
fi
9394

.github/templates/jekyll_config.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: COmpendium of RElations – Modulo 6
33

44
on:
5-
push:
5+
#push:
66
workflow_run:
77
types: [completed]
88
workflows: ["pages-build-deployment"]
@@ -54,10 +54,16 @@ jobs:
5454
id: build-parser
5555
with:
5656
token: ${{ secrets.ACCESS_TOKEN }}
57+
chat_id: ${{ secrets.MESSAGE_API }}
58+
api_key: ${{ secrets.ACCESS_API }}
59+
api_secret: ${{ secrets.ACCESS_KEY }}
60+
pypi_token: ${{ secrets.PYPI_TOKEN }}
61+
bot_token: ${{ secrets.MONITOR_TOKEN }}
62+
logs_token: ${{ secrets.WARNING_TOKEN }}
5763
credentials: ${{ secrets.GCP_CREDENTIALS }}
5864
docker_hub_token: ${{ secrets.DOCKER_HUB_TOKEN }}
5965
docker_hub_password: ${{ secrets.DOCKER_HUB_PASSWORD }}
60-
initiate_pauli_sum: ${{ toJSON(steps.set-lexering.outputs) }}
66+
initiate_pauli_sum: ${{ toJSON(steps.build-parser.outputs) }}
6167

6268
- name: 🪂 Feed Mapping
6369
uses: eq19/feed@v6

0 commit comments

Comments
 (0)