Skip to content

Updating README.md file #6

Updating README.md file

Updating README.md file #6

Workflow file for this run

name: Create and Push Agent TGZ to Main
on:
push:
branches:
- main
paths:
- 'apps/agent/**'
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Enable Corepack
run: |
corepack enable
corepack prepare yarn@4.5.0 --activate
- name: Install dependencies
run: yarn install
- name: Build and bundle
run: |
cd apps/agent
yarn bundle
- name: Rename bundle
run: mv apps/agent/dist/*.tgz apps/agent/dist/agent-${{ github.sha }}.tgz
- name: Upload TGZ as artifact
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
artifact_name="agent-${{ github.sha }}.tgz"
artifact_path="apps/agent/dist/$artifact_name"
# Verify file exists
if [ ! -f "$artifact_path" ]; then
echo "Error: File $artifact_path does not exist"
exit 1
fi
# Create a new artifact
response=$(curl -sS -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/actions/artifacts" \
-d "{\"name\":\"$artifact_name\",\"retention_days\":1}")
echo "API Response: $response"
# Check for errors in the response
if echo "$response" | jq -e '.message' > /dev/null; then
echo "Error from GitHub API: $(echo "$response" | jq -r '.message')"
exit 1
fi
upload_url=$(echo "$response" | jq -r '.upload_url')
if [ -z "$upload_url" ] || [ "$upload_url" = "null" ]; then
echo "Error: Failed to get upload URL from GitHub API"
exit 1
fi
# Upload the artifact
upload_response=$(curl -sS -X PUT \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/gzip" \
-T "$artifact_path" \
"$upload_url")
echo "Upload Response: $upload_response"
# Check for errors in the upload response
if echo "$upload_response" | jq -e '.message' > /dev/null; then
echo "Error uploading artifact: $(echo "$upload_response" | jq -r '.message')"
exit 1
fi
echo "Artifact $artifact_name uploaded successfully"