Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
theosanderson committed Nov 30, 2023
1 parent 3ce9f8d commit f4eff6e
Showing 1 changed file with 20 additions and 26 deletions.
46 changes: 20 additions & 26 deletions .github/workflows/update-argocd-metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,24 @@ jobs:
check-name: Build Website Docker Image
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Update config.json in argocd_metadata
if: github.ref == 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout External Repository
uses: actions/checkout@v3
with:
repository: 'pathoplexus/argocd_metadata' # Replace with the correct repository path
# token: ${{ secrets.PAT }} # Personal Access Token with appropriate permissions

- name: Modify config.json
run: |
# Assuming config.json is in the root directory of the repository
# Perform necessary modifications here. Example:
echo '{
"new_key": "new_value"
}' > config.json
- name: Commit and Push Changes
run: |
# Fetching the current content of config.json from the repository
curl -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/pathoplexus/argocd_metadata/contents/config.json" \
-o config.json
# Extracting the SHA of the current config.json for update purposes
CONFIG_SHA=$(jq -r '.sha' config.json)
# Updating the file with the new SHA
NEW_CONTENT=$(jq '.head_short_sha_7 = "'$(echo $GITHUB_SHA | cut -c1-7)'"' config.json | base64)
# Preparing the payload for updating the file in the repository
PAYLOAD=$(jq -n --arg content "$NEW_CONTENT" \
--arg sha "$CONFIG_SHA" \
'{message: "Update head_short_sha_7", content: $content, sha: $sha}')
# Pushing the updated content back to the repository
curl -X PUT -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
-d "$PAYLOAD" \
"https://api.github.com/repos/pathoplexus/argocd_metadata/contents/config.json"
git config --global user.name 'Your Name'
git config --global user.email 'your-email@example.com'
git add config.json
git commit -m "Update config.json"
git push

0 comments on commit f4eff6e

Please sign in to comment.