Skip to content

Commit 56355e0

Browse files
committed
update workflows
1 parent bac0d6d commit 56355e0

File tree

411 files changed

+53674
-81
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

411 files changed

+53674
-81
lines changed

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
name: 'Docker Deploy Action'
2+
3+
description: >
4+
🪂 A Github Action to deploy pages conveniently
5+
6+
branding:
7+
icon: 'command'
8+
color: 'red'
9+
10+
inputs:
11+
id:
12+
description: The deploy id
13+
required: false
14+
hub_username:
15+
description: Username for Docker Hub
16+
default: ${{ github.actor }}
17+
required: true
18+
hub_password:
19+
description: Docker Hub authentication token
20+
required: true
21+
hub_token:
22+
description: Docker Hub authentication token
23+
required: true
24+
action_path:
25+
description: Path to the dockerfile from which to build the image
26+
required: true
27+
credentials:
28+
description: 'The gcloud credentials'
29+
required: true
30+
image_name:
31+
description: Tag to use for the new image
32+
default: ${{ github.action_repository }}
33+
required: true
34+
dockerfile_path:
35+
description: Path to the dockerfile from which to build the image
36+
required: true
37+
initiate_pauli_sum:
38+
description: Build args
39+
required: false
40+
default: ""
41+
docker_hub_repo_short_description:
42+
description: Short description text for the docker hub repo
43+
required: true
44+
docker_hub_repo_readme_file_path:
45+
description: |
46+
Path of the md file which will be used as the docker hub repo readme
47+
required: true
48+
cache_src:
49+
description: Path for the docker cache source
50+
required: false
51+
default: /tmp/.buildx-cache
52+
cache_dest:
53+
description: Path for the docker cache destination
54+
required: false
55+
default: /tmp/.buildx-cache-new
56+
owner:
57+
description: 'The deploy owner'
58+
required: false
59+
token:
60+
description: 'The deploy token'
61+
required: false
62+
repository:
63+
description: 'The deploy repository'
64+
default: ${{ github.repository }}
65+
required: false
66+
api_key:
67+
description: The key of api application
68+
required: true
69+
api_secret:
70+
description: The secret of api application
71+
required: true
72+
pypi_token:
73+
description: The pypi token
74+
required: true
75+
bot_token:
76+
description: The monitor token
77+
required: true
78+
logs_token:
79+
description: The warning token
80+
required: true
81+
chat_id:
82+
description: The telegram chat id
83+
required: true
84+
85+
outputs:
86+
artifact:
87+
description: Collect artifact outputs
88+
value: ${{ toJSON(steps.artifact.outputs) }}
89+
variables:
90+
description: Collect variables outputs
91+
value: ${{ toJSON(steps.variables.outputs) }}
92+
93+
runs:
94+
using: composite
95+
steps:
96+
- name: Remove Existing Connection
97+
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 }}
104+
run: |
105+
gh variable set RERUN_RUNNER --body "false"
106+
107+
HEADER="Accept: application/vnd.github+json"
108+
RESPONSE=$(gh api -H "${HEADER}" repos/${{ github.repository }}/actions/runners)
109+
TOTAL_COUNT=$(gh api -H "${HEADER}" /repos/${{ github.repository }}/actions/runners --jq '.total_count')
110+
STATUS=$(echo "$RESPONSE" | jq -r --arg NAME "${{ env.RUNNER_TITLE }}" '.runners[] | select(.name == $NAME).status')
111+
112+
if [[ "$TOTAL_COUNT" -eq 0 ]]; then
113+
export "RUNNER_COUNT=$TOTAL_COUNT"
114+
gh variable set RERUN_RUNNER --body "true"
115+
elif [[ "$STATUS" == "offline" ]]; then
116+
export "RUNNER_STATUS=$STATUS"
117+
gh variable set RERUN_RUNNER --body "true"
118+
RUNNER_ID=$(gh api -H "${HEADER}" /repos/${{ github.repository }}/actions/runners --jq '.runners.[].id')
119+
gh api --method DELETE -H "${HEADER}" /repos/${{ github.repository }}/actions/runners/${RUNNER_ID}
120+
fi
121+
122+
/home/runner/work/_actions/eq19/eq19/v2/.github/entrypoint/init.sh ${{ inputs.action_path }}
123+
mv -f /home/runner/work/_actions/eq19/eq19/v2/.github/entrypoint/dockerfile/* ${{ inputs.action_path }}/
124+
125+
- name: View context attributes
126+
uses: actions/github-script@v7
127+
with:
128+
script: console.log(context)
129+
130+
#- uses: actions/setup-python@v5
131+
#with:
132+
#python-version: 3.12
133+
#allow-prereleases: true
134+
135+
#- uses: actions/cache@v4
136+
#with:
137+
#path: ~/.cache/pip
138+
#key: ${{ runner.os }}-pip
139+
140+
- name: Install dependencies
141+
shell: bash
142+
env:
143+
ACCESS_API: ${{ inputs.api_key }}
144+
ACCESS_KEY: ${{ inputs.api_secret }}
145+
ACCESS_TOKEN: ${{ inputs.token }}
146+
MESSAGE_API: ${{ inputs.chat_id }}
147+
MONITOR_TOKEN: ${{ inputs.bot_token }}
148+
WARNING_TOKEN: ${{ inputs.logs_token }}
149+
PYPI_TOKEN: ${{ inputs.pypi_token }}
150+
DOCKER_HUB_TOKEN: ${{ inputs.hub_token }}
151+
DOCKER_HUB_PASSWORD: ${{ inputs.hub_password }}
152+
GCP_CREDENTIALS: ${{ inputs.credentials }}
153+
run: |
154+
# Get all secrets from source repository
155+
secrets=$(curl -s -H "Authorization: token $GH_TOKEN" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${{ github.repository }}/actions/secrets" | jq -r '.secrets[].name')
156+
for secret in $secrets; do gh secret set $secret --repo ${{ env.TARGET_REPOSITORY }} --body "${!secret}"; done
157+
158+
#python -m pip -q install --upgrade pip
159+
#python -m pip -q install -r ${{ inputs.action_path }}/dataFile/requirements.txt
160+
161+
##python -m pip -q install -e ./.github/entrypoint/artifact/python
162+
##iree-compile --iree-llvmcpu-list-targets && iree-run-module --list_drivers
163+
164+
##Ref: https://github.com/iree-org/iree-experimental
165+
##python ${{ inputs.action_path }}/pythonCode/testIREE.py
166+
167+
##Ref: https://github.com/tsoding/JelloVM
168+
#cd ${{ inputs.action_path }} && javac javaCode/Main.java
169+
170+
##Ref: https://github.com/eq19/maps/tree/v3/pythonCode
171+
##python ${{ github.workspace }}/.github/entrypoint/artifact/python/gellmann.py
172+
##cd ${{ inputs.action_path }}/pythonCode && python npreader.py -h && python map.py -h
173+
174+
- name: Login to DockerHub
175+
uses: docker/login-action@v3
176+
with:
177+
username: ${{ inputs.hub_username }}
178+
password: ${{ inputs.hub_token }}
179+
180+
- name: 🚀 Initiate Lexer
181+
uses: devcontainers/[email protected]
182+
with:
183+
runCmd: ls -al /
184+
skipContainerUserIdUpdate: true
185+
imageName: ${{ inputs.image_name }}
186+
imageTag: target-${{ github.run_number }}
187+
configFile: ${{ inputs.action_path }}/.devcontainer.json
188+
push: ${{ env.RERUN_RUNNER == 'true' && 'always' || 'never' }}
189+
190+
- name: 🗑️ Delete Docker Tags AND Images
191+
id: delete_images
192+
shell: bash
193+
env:
194+
IMAGE_NAME: "${{ inputs.image_name }}"
195+
HUB_USERNAME: "${{ inputs.hub_username }}"
196+
HUB_PASSWORD: "${{ inputs.hub_password }}"
197+
MAX_DELETIONS: 15
198+
run: |
199+
./.github/entrypoint/remote.sh
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
name: 'Docker Deploy Action'
2+
3+
description: >
4+
🪂 A Github Action to deploy pages conveniently
5+
6+
branding:
7+
icon: 'command'
8+
color: 'red'
9+
10+
inputs:
11+
id:
12+
description: The deploy id
13+
required: false
14+
hub_username:
15+
description: Username for Docker Hub
16+
default: ${{ github.actor }}
17+
required: true
18+
hub_password:
19+
description: Docker Hub authentication token
20+
required: true
21+
hub_token:
22+
description: Docker Hub authentication token
23+
required: true
24+
action_path:
25+
description: Path to the dockerfile from which to build the image
26+
required: true
27+
credentials:
28+
description: 'The gcloud credentials'
29+
required: true
30+
image_name:
31+
description: Tag to use for the new image
32+
default: ${{ github.action_repository }}
33+
required: true
34+
dockerfile_path:
35+
description: Path to the dockerfile from which to build the image
36+
required: true
37+
initiate_pauli_sum:
38+
description: Build args
39+
required: false
40+
default: ""
41+
docker_hub_repo_short_description:
42+
description: Short description text for the docker hub repo
43+
required: true
44+
docker_hub_repo_readme_file_path:
45+
description: |
46+
Path of the md file which will be used as the docker hub repo readme
47+
required: true
48+
cache_src:
49+
description: Path for the docker cache source
50+
required: false
51+
default: /tmp/.buildx-cache
52+
cache_dest:
53+
description: Path for the docker cache destination
54+
required: false
55+
default: /tmp/.buildx-cache-new
56+
owner:
57+
description: 'The deploy owner'
58+
required: false
59+
token:
60+
description: 'The deploy token'
61+
required: false
62+
repository:
63+
description: 'The deploy repository'
64+
default: ${{ github.repository }}
65+
required: false
66+
api_key:
67+
description: The key of api application
68+
required: true
69+
api_secret:
70+
description: The secret of api application
71+
required: true
72+
pypi_token:
73+
description: The pypi token
74+
required: true
75+
bot_token:
76+
description: The monitor token
77+
required: true
78+
logs_token:
79+
description: The warning token
80+
required: true
81+
chat_id:
82+
description: The telegram chat id
83+
required: true
84+
85+
outputs:
86+
artifact:
87+
description: Collect artifact outputs
88+
value: ${{ toJSON(steps.artifact.outputs.repo) }}
89+
set_output:
90+
description: Collect set_output outputs
91+
value: ${{ toJSON(steps.set_output.outputs) }}
92+
93+
runs:
94+
using: composite
95+
steps:
96+
- name: 💎 Set ID Token
97+
id: 'auth'
98+
uses: 'google-github-actions/auth@v2'
99+
with:
100+
token_format: 'id_token'
101+
create_credentials_file: false
102+
credentials_json: ${{ inputs.credentials }}
103+
id_token_audience: 'https://us-central1-feedmapping.cloudfunctions.net/function'
104+
105+
- name: 💎 Set Artifact
106+
id: artifact
107+
shell: bash
108+
run: |
109+
shopt -s dotglob
110+
rm -rf ${{ inputs.action_path }}/.git
111+
112+
mv -f ${{ runner.temp }}/.env ${{ inputs.action_path }}/
113+
mv -f ${{ runner.temp }}/_config.yml ${{ inputs.action_path }}/
114+
115+
mkdir -p ${{ inputs.action_path }}/_data
116+
mv -f ${{ runner.temp }}/*.json ${{ inputs.action_path }}/_data/
117+
118+
mv -f ${{ inputs.action_path }} ${{ github.workspace }}/_site
119+
mkdir -p ${{ inputs.action_path }} && cp -R ${{ github.workspace }}/_site/. ${{ inputs.action_path }}/
120+
121+
- uses: ikalnytskyi/action-setup-postgres@v7
122+
id: postgres
123+
with:
124+
username: yoda
125+
password: GrandMaster
126+
database: jedi_order
127+
port: 34837
128+
postgres-version: "17"
129+
ssl: true
130+
131+
- name: 🪂 Test postgres
132+
env:
133+
CONNECTION_URI: ${{ steps.postgres.outputs.connection-uri }}
134+
SERVICE_NAME: ${{ steps.postgres.outputs.service-name }}
135+
CERTIFICATE_PATH: ${{ steps.postgres.outputs.certificate-path }}
136+
EXPECTED_CONNECTION_URI: postgresql://yoda:GrandMaster@localhost:34837/jedi_order?sslmode=verify-ca&sslrootcert=${{ steps.postgres.outputs.certificate-path }}
137+
EXPECTED_SERVICE_NAME: yoda
138+
EXPECTED_SERVER_VERSION: 17
139+
EXPECTED_SSL: true
140+
shell: bash
141+
run: |
142+
##cd /home/runner/work/_actions/eq19/eq19/v2/integrations/tensorflow
143+
##pip install -e python_projects/* && iree-import-tflite -h && iree-import-tf -h
144+
145+
##cd /home/runner/work/_actions/eq19/eq19/v2/integrations/pjrt
146+
##pip install -e ctstools python_packages/iree_cpu_plugin
147+
148+
##pip install -r requirements.txt && cd python_packages/iree_cpu_plugin/build/cmake && ninja
149+
##JAX_PLATFORMS=iree-cpu pytest -n4 --max-worker-restart=9999 -p openxla_pjrt_artifacts --openxla-pjrt-artifact-dir=/tmp/foobar test/test_simple.py
150+
151+
#cp ${{ github.workspace }}/.github/entrypoint/test.py . && python3 -m pytest -vv test.py
152+
#python ${{ github.workspace }}/web_programming/cc_exchanges.py
153+
154+
- name: 🚀 Initiate Feed Container
155+
if: runner.os != 'Windows'
156+
uses: devcontainers/[email protected]
157+
id: set_output
158+
with:
159+
imageTag: spin-${{ env.ID }}
160+
skipContainerUserIdUpdate: true
161+
imageName: ${{ inputs.image_name }}
162+
configFile: _site/.devcontainer.json
163+
env: |
164+
ID=${{ env.ID }}
165+
GH_TOKEN=${{ env.GH_TOKEN }}
166+
REMOTE_REPO=${{ env.REMOTE_REPO }}
167+
BEARER=${{ steps.auth.outputs.id_token }}
168+
TARGET_REPOSITORY=${{ env.TARGET_REPOSITORY }}
169+
push: ${{ env.RERUN_RUNNER == 'true' && 'always' || 'never' }}
170+
runCmd: bash user_data/ft_client/test_client/test_rest_client.sh
171+
172+
- name: 🪂 Remove existing images
173+
id: variables
174+
shell: bash
175+
run: |
176+
BASE_NAME=$(basename ${{ inputs.image_name }})
177+
IFS=', '; array=($(curl -L -s 'https://registry.hub.docker.com/v2/repositories/${{ inputs.image_name }}/tags?page_size=1024' | jq -rc '."results"[]["name"]' | yq eval -P | sed "s/ /, /g"))
178+
for ((i=0; i < ${#array[@]}; i++)); do
179+
if [[ "${array[$i]}" != "latest" ]]; then
180+
HUB_TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"${{ inputs.hub_username }}\", \"password\": \"${{ inputs.hub_password }}\"}" https://hub.docker.com/v2/users/login/ | jq -r .token)
181+
curl -s -i -X DELETE -H "Accept: application/json" -H "Authorization: JWT $HUB_TOKEN" https://hub.docker.com/v2/namespaces/${{ inputs.hub_username }}/repositories/$BASE_NAME/tags/${array[$i]}
182+
echo "deleted: ${{ inputs.image_name }}:${array[$i]}"
183+
fi
184+
done

0 commit comments

Comments
 (0)