Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump main #21

Merged
merged 27 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4fa0a07
Add access token for private repo support
cheran-senthil Sep 9, 2024
fd42922
Change env var type
cheran-senthil Sep 9, 2024
a1b78f1
Update default
cheran-senthil Sep 9, 2024
926f7f4
Fix get env var logic
cheran-senthil Sep 9, 2024
5708113
Simplify env var access
cheran-senthil Sep 9, 2024
b2968e7
Add decryption of access token
cheran-senthil Sep 12, 2024
018d88a
Revert env var name
cheran-senthil Sep 12, 2024
ed05185
Remove reinstall
cheran-senthil Sep 12, 2024
30074b4
Add export
cheran-senthil Sep 12, 2024
aff3318
Export correctly
cheran-senthil Sep 12, 2024
20eac58
Use correct substitution syntax
cheran-senthil Sep 12, 2024
1758b10
Replace with env for clone
cheran-senthil Sep 12, 2024
f34093c
Use token directly
cheran-senthil Sep 12, 2024
ff57729
Add debug info
cheran-senthil Sep 12, 2024
f4b7663
Add decryption file
cheran-senthil Sep 12, 2024
5aae4c4
Combine these steps
cheran-senthil Sep 12, 2024
cf2eb3b
[ENG-179] Allow env var for node version (#16)
cheran-senthil Sep 18, 2024
3eead18
Fix for index.html check
cheran-senthil Sep 18, 2024
eea223f
Add special case for .
cheran-senthil Sep 18, 2024
0c85708
Revert this code
cheran-senthil Sep 18, 2024
316b182
Revert this because signature error
cheran-senthil Sep 18, 2024
e5922cd
Add custom branch param
cheran-senthil Sep 18, 2024
c8759c1
Add mirror workflow
dmanjunath Sep 20, 2024
32de7e7
remove test branch
dmanjunath Sep 20, 2024
5ed5ab1
Add test for secrets
cheran-senthil Sep 23, 2024
ec63334
Add CI Trigger param to circleci config (#20)
dmanjunath Sep 23, 2024
f9af8e8
Merge branch 'main' into dev
cheran-senthil Sep 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,26 @@ parameters:
SOURCE_TYPE:
type: string
default: "github"
CI_TRIGGER:
type: boolean
default: true


jobs:
publish:
docker:
- image: cimg/base:stable
steps:
- run:
name: Check CI_TRIGGER
command: |
if [ "<< pipeline.parameters.CI_TRIGGER >>" != true ]; then
echo "CI_TRIGGER is not true. Exiting with success."
circleci-agent step halt
else
echo "CI_TRIGGER is true. Continuing with the workflow."
fi

- run:
name: Install AWS CLI
command: |
Expand Down Expand Up @@ -91,17 +105,32 @@ jobs:
echo " });" >> ~/project/decrypt.js
echo "}" >> ~/project/decrypt.js
echo "" >> ~/project/decrypt.js
echo "const encryptedData = process.argv[2];" >> ~/project/decrypt.js
echo "console.log(decryptData(encryptedData));" >> ~/project/decrypt.js
echo "const input = process.argv[2];" >> ~/project/decrypt.js
echo "try {" >> ~/project/decrypt.js
echo " const parsedJson = JSON.parse(input);" >> ~/project/decrypt.js
echo " const decryptedJson = Object.keys(parsedJson).reduce((acc, key) => {" >> ~/project/decrypt.js
echo " acc[key] = decryptData(parsedJson[key]);" >> ~/project/decrypt.js
echo " return acc;" >> ~/project/decrypt.js
echo " }, {});" >> ~/project/decrypt.js
echo " console.log(JSON.stringify(decryptedJson));" >> ~/project/decrypt.js
echo "} catch (e) {" >> ~/project/decrypt.js
echo " // If parsing fails, assume it's a single encrypted token" >> ~/project/decrypt.js
echo " console.log(decryptData(input));" >> ~/project/decrypt.js
echo "}" >> ~/project/decrypt.js

- run:
name: Decode secrets and environment variables
command: |
if [ -n "<< pipeline.parameters.SECRETS >>" ]; then
echo "Decoding secrets..."
node ~/project/decrypt.js "<< pipeline.parameters.SECRETS >>" > ~/project/decrypted_secrets.txt
sed -i 's/^/export /' ~/project/decrypted_secrets.txt
DECRYPTED_JSON=$(node ~/project/decrypt.js '<< pipeline.parameters.SECRETS >>')
if [[ $DECRYPTED_JSON == {* ]]; then
echo "$DECRYPTED_JSON" | jq -r 'to_entries | map("export \(.key)=\(.value|@sh)") | .[]' > ~/project/decrypted_secrets.txt
else
echo "export DECRYPTED_SECRET=$DECRYPTED_JSON" > ~/project/decrypted_secrets.txt
fi
source ~/project/decrypted_secrets.txt
cat ~/project/decrypted_secrets.txt
fi

if [ -n "<< pipeline.parameters.ENVIRONMENT_VARIABLES >>" ]; then
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/mirror-private-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ jobs:
exit 1
fi

# Ensure this is only run in the dashboard-runner repository
REPO_NAME=$(basename -s .git `git config --get remote.origin.url`)
if [ "$REPO_NAME" != "dashboard-runner" ]; then
echo "This action is only allowed to run in the dashboard-runner repository."
exit 0
fi

# Clone the source repository
git clone --mirror https://${GH_TOKEN}@github.com/earthfast/dashboard-runner.git source-repo
cd source-repo
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/trigger-circleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ jobs:
echo "::set-output name=branch::main"
fi

- name: Ensure repository is dashboard-runner
run: |
REPO_NAME=$(basename -s .git `git config --get remote.origin.url`)
if [ "$REPO_NAME" != "dashboard-runner" ]; then
echo "This action is only allowed to run in the earthfast/dashboard-runner repository."
exit 0
fi

- name: Trigger CircleCI Pipeline
run: |
curl -X POST \
Expand All @@ -41,7 +49,8 @@ jobs:
"OUTPUT_DIR": ".",
"ENVIRONMENT_VARIABLES": "",
"ONE_CLICK_SERVER_URL": "https://jorge.ngrok.pro",
"ENVIRONMENT": "${{ steps.env-branch.outputs.environment }}"
"ENVIRONMENT": "${{ steps.env-branch.outputs.environment }}",
"CI_TRIGGER": true
}
}' \
https://circleci.com/api/v2/project/gh/earthfast/dashboard-runner/pipeline
Expand Down
Loading