diff --git a/.github/scripts/copy-from-s3-to-gcp.sh b/.github/scripts/copy-from-s3-to-gcp.sh new file mode 100755 index 000000000..f6b52390e --- /dev/null +++ b/.github/scripts/copy-from-s3-to-gcp.sh @@ -0,0 +1,14 @@ +s3_url=$1 +gcp_url=$2 + +# Process s3_url remove trailing / and get the last segment without the trailing / +file_name=${s3_url%/} +file_name=${file_name##*/} + +# Download from S3 then upload to GCP +aws s3 cp $s3_url . --recursive --no-progress +echo "-------" +ls +echo "-------" +gcp storage cp $gcp_url ./$file_name --recursive +rm -rf $file_name \ No newline at end of file diff --git a/.github/workflows/backup-eclipse-releases-to-gcp.yml b/.github/workflows/backup-eclipse-releases-to-gcp.yml new file mode 100644 index 000000000..9fcddb1d3 --- /dev/null +++ b/.github/workflows/backup-eclipse-releases-to-gcp.yml @@ -0,0 +1,49 @@ +name: Backup Eclipse Releases to GCP + +on: + workflow_dispatch: + inputs: + ls_version: + description: The suffix of the p2 repo URL in S3 (i.e. 2023-11-01) + required: true + type: string + release_version: + description: Release version (i.e. 4.20.1) + required: true + type: string + +env: + AWS_ACCESS_KEY_ID: ${{ secrets.CDN_S3_ACCESS_KEY }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.CDN_S3_SECRET_KEY }} + AWS_DEFAULT_REGION: us-east-1 + AWS_ENDPOINT_URL_S3: ${{ secrets.CDN_S3_ENDPOINT }} + AWS_S3_BUCKET: ${{ secrets.CDN_BUCKET }} + DOWNLOAD_URL_ROOT: https://cdn.spring.io/spring-tools + +jobs: + backup-eclipse-releases-to-gcp: + runs-on: ubuntu-latest + name: Backup Eclipse releases for version '${{ inputs.release_version }}' + steps: + - name: Authenticate to GCP + run: | + echo -e "${{ secrets.CDN_SPRING_IO_BACKUP_GCP_BUCKET_JSON }} " > ~/gcp.json + gcloud auth activate-service-account --key-file=~/gcp.json + - uses: actions/checkout@v4 + with: + sparse-checkout: | + .github/scripts + - name: Download from S3, Upload to GCP + run: | + url_path=spring-tools/release/TOOLS/sts4-language-server-integrations/${{ inputs.ls_version }} + + echo "Copying Eclipse LS extensions ${{ inputs.ls_version }} to GCP..." + ${{ github.workspace }}/.github/scripts/copy-from-s3-to-gcp.sh s3://$AWS_S3_BUCKET/$url_path gs://gcp-test-spring-io/$url_path + + echo "Copying Eclipse Distro P2 repos ${{ inputs.ls_version }} to GCP..." + url_path=spring-tools/release/TOOLS/sts4/update/${{ inputs.release_version }}.RELEASE + ${{ github.workspace }}/.github/scripts/copy-from-s3-to-gcp.sh s3://$AWS_S3_BUCKET/$url_path gs://gcp-test-spring-io/$url_path + + echo "Copying Eclipse Distros ${{ inputs.release_version }} to GCP..." + url_path=spring-tools/release/STS4/${{ inputs.release_version }}.RELEASE/dist + ${{ github.workspace }}/.github/scripts/copy-from-s3-to-gcp.sh s3://$AWS_S3_BUCKET/$url_path gs://gcp-test-spring-io/$url_path