Skip to content

Commit

Permalink
Update upstream_sync.yml (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
karan-batavia authored Nov 21, 2024
1 parent 5677580 commit 4e7f147
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions .github/workflows/upstream_sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,40 @@ jobs:

- name: Get latest upstream release
run: |
echo "LATEST_TAG=$(curl -L \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/joernio/joern/releases/latest | jq -r .name | sed 's/[v]//g' | sed 's/[.]/-/g' )" >> $GITHUB_ENV
# Fetch the latest release tag from the GitHub API
RAW_RELEASE_TAG=$(curl -L \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/joernio/joern/releases/latest | jq -r .name)
# Process the tag to create the desired format
LATEST_TAG=$(echo "$RAW_RELEASE_TAG" | sed 's/^v//' | sed 's/\./-/g')
# Export to GitHub environment variables
echo "RAW_RELEASE_TAG=$RAW_RELEASE_TAG" >> $GITHUB_ENV
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
- name: Create tag branch and merge upstream
uses: peterjgrainger/action-create-branch@v2.2.0
run: |
# Get the latest commit url
COMMIT_URL=$(curl -v \
-H "Authorization: Bearer ${{ env.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/joernio/joern/git/ref/tags/${{ env.RAW_RELEASE_TAG }} \
| jq -r '.object.url')
# Get SHA from the commit URL
COMMIT_SHA=$(curl -L \
-H "Accept: application/vnd.github+json" \
$COMMIT_URL | jq -r .object.sha)
# Create a branch pointing to the commit
curl -X POST \
-H "Authorization: Bearer ${{ env.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github+json" \
-d '{"ref": "refs/heads/'"${LATEST_TAG}"'", "sha": "'"${COMMIT_SHA}"'"}' \
https://api.github.com/repos/Privado-Inc/joern/git/refs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: ${{ env.LATEST_TAG }}
GITHUB_TOKEN: ${{ secrets.CORE_AT }}

- run: bash ./upstream_sync.sh --branch ${{ env.LATEST_TAG }}
env:
Expand All @@ -33,4 +57,4 @@ jobs:
- name: Create a PR from ${{ env.LATEST_TAG }} to sync
run: gh pr create --repo Privado-Inc/joern -B backup_sync -H ${{ env.LATEST_TAG }} --title 'Merge ${{ env.LATEST_TAG }} to backup_sync' --body 'Created by Github action'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 4e7f147

Please sign in to comment.