From 8e62f8ba8d7ace2f6d89f3edd5c9490fd50fc921 Mon Sep 17 00:00:00 2001 From: Montse Ortega Date: Mon, 7 Oct 2024 14:21:25 +0200 Subject: [PATCH] Modifying push-to-main workflow action --- .github/workflows/push-to-main.yaml | 59 ++++------------------------- 1 file changed, 8 insertions(+), 51 deletions(-) diff --git a/.github/workflows/push-to-main.yaml b/.github/workflows/push-to-main.yaml index f92b3c1..d8eeec9 100644 --- a/.github/workflows/push-to-main.yaml +++ b/.github/workflows/push-to-main.yaml @@ -34,54 +34,11 @@ jobs: - 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" + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: agent-${{ github.sha }}.tgz + path: apps/agent/dist/agent-${{ github.sha }}.tgz + if-no-files-found: error + retention-days: 1 + compression-level: 0 \ No newline at end of file