Skip to content

Commit e6695a1

Browse files
authored
Merge pull request #25 from codio/codio-17207-github-action-aws-new
Codio GitHub action aws new
2 parents 10583f2 + b30e564 commit e6695a1

2 files changed

Lines changed: 22 additions & 16 deletions

File tree

.github/workflows/release.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,26 @@ on:
33
release:
44
types: [created]
55

6+
permissions:
7+
contents: write
8+
id-token: write
9+
610
jobs:
711
build:
812
runs-on: ubuntu-latest
913
steps:
1014
- name: Checkout
11-
uses: actions/checkout@v4
15+
uses: actions/checkout@v5
16+
17+
- name: Configure AWS Credentials
18+
uses: aws-actions/configure-aws-credentials@v5.1.0
19+
with:
20+
aws-region: us-east-1
21+
role-to-assume: arn:aws:iam::028537455170:role/Github/GithubAssetsUploadRole_noVNC-client
22+
role-session-name: GithubAction
1223

1324
- name: Upload to s3
14-
run: ./uploadToS3.sh "${{ secrets.ASSETS_UPLOADER_KEY }}" "${{ secrets.ASSETS_UPLOADER_SECRET }}" "${{ github.event.release.tag_name }}"
25+
run: ./uploadToS3.sh "${{ github.event.release.tag_name }}"
1526

1627
- name: Slack
1728
uses: codio/codio-slack-action@master

uploadToS3.sh

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
#!/bin/bash
22
set -xe
33

4-
s3Key=$1
5-
s3Secret=$2
6-
tag=$3
4+
tag=$1
75
folder="noVNC"
86
cdn="\/\/static-assets.codio.com\/${folder}\/${tag}"
97

@@ -17,16 +15,20 @@ replaceTagVersion () {
1715

1816
replaceJsUrls () {
1917
sed -i "s/\.\/package\.json/${cdn}\/package\.json/" "./app/ui.js"
18+
sed -i "s/\"app\//\"${cdn}\/app\//" "./app/ui.js"
2019
}
2120

2221
prepareSources () {
2322
replaceHtmlUrls "href=\"app\/" "href=\"${cdn}\/app\/"
2423
replaceHtmlUrls "src=\"app\/" "src=\"${cdn}\/app\/"
24+
replaceHtmlUrls "from \".\/" "from \"${cdn}\/"
25+
replaceHtmlUrls "from '.\/" "from '${cdn}\/"
26+
replaceHtmlUrls "fetch('.\/" "fetch('${cdn}\/"
2527
replaceTagVersion
2628
replaceJsUrls
2729
}
2830

29-
readarray -d '' files < <(find ./ -type f -print0)
31+
readarray -d '' files < <(find ./ -type f -not -path "*/.git/*" -not -path "*/.github/*" -print0)
3032

3133
getContentType () {
3234
filename=$1
@@ -58,16 +60,9 @@ uploadFile () {
5860
fName="${file#./}"
5961
contentType=$2
6062
bucket="codio-assets"
61-
resource="/${bucket}/${folder}/${tag}/${fName}"
62-
dateValue=$(date -R)
63-
stringToSign="PUT\n\n${contentType}\n${dateValue}\n${resource}"
64-
signature=$(echo -en "${stringToSign}" | openssl sha1 -hmac "${s3Secret}" -binary | base64)
65-
curl -X PUT -T "${file}" \
66-
-H "Host: ${bucket}.s3.amazonaws.com" \
67-
-H "Date: ${dateValue}" \
68-
-H "Content-Type: ${contentType}" \
69-
-H "Authorization: AWS ${s3Key}:${signature}" \
70-
https://${bucket}.s3.amazonaws.com/"${folder}"/"${tag}"/"${fName}" || exit 1
63+
resource="s3://${bucket}/${folder}/${tag}/${fName}"
64+
65+
aws s3 cp "${file}" "${resource}" --cache-control no-cache --content-type "${contentType}"
7166
}
7267

7368
prepareSources

0 commit comments

Comments
 (0)