Skip to content

Commit

Permalink
feat(github): add script to upload s3
Browse files Browse the repository at this point in the history
  • Loading branch information
ikr4-m committed Aug 15, 2024
1 parent c83a602 commit 7b347ba
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions .github/workflows/reusable-upload-s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ name: Reusable workflow for upload file to S3

on:
workflow_call:
#secrets:
# AWS_ACCESS_KEY_ID:
# required: true
# AWS_SECRET_ACCESS_KEY:
# required: true
secrets:
BUCKET_URL:
required: true
BUCKET_USERNAME:
required: true
BUCKET_PASSWORD:
required: true
BUCKET_NAME:
required: true
inputs:
binary_name:
type: string
Expand All @@ -22,5 +26,30 @@ jobs:
name: ${{ inputs.binary_name }}-build-artifact
- name: Check file
run: |
ls -lah
pwd
ls -lah
- name: Install curl + openssl
run: |
apt update
apt install -y curl openssl
- name: Upload file
run: |
URL=${{ secrets.BUCKET_URL }}
USERNAME=${{ secrets.BUCKET_USERNAME }}
PASSWORD=${{ secrets.BUCKET_PASSWORD }}
BUCKET=${{ secrets.BUCKET_NAME }}
MINIO_PATH="/${BUCKET}/."
FILE=${{ inputs.binary_name }}
DATE=$(date -R --utc)
CONTENT_TYPE='binary/octet-stream'
SIG_STRING="PUT\n\n${CONTENT_TYPE}\n${DATE}\n${MINIO_PATH}"
SIGNATURE=`echo -en ${SIG_STRING} | openssl sha1 -hmac ${PASSWORD} -binary | base64`
curl -T $FILE\
-X PUT \
-H "Host: $URL" \
-H "Date: ${DATE}" \
-H "Content-Type: ${CONTENT_TYPE}" \
-H "Authorization: AWS ${USERNAME}:${SIGNATURE}" \
https://$URL${MINIO_PATH}

0 comments on commit 7b347ba

Please sign in to comment.