Skip to content

Commit 84fbd26

Browse files
github: Use IAM Roles to push files on AWS S3 (#42)
For security reasons long lived credentials are not considered secure. To overcome this issue we can configure Github Workflows to use AWS OpenID Connect instead: For further details: https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect
1 parent 386b3eb commit 84fbd26

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

.github/workflows/release-go-task.yml

+12-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ env:
77
# As defined by the Taskfile's DIST_DIR variable
88
DIST_DIR: dist
99
# The project's folder on Arduino's download server for uploading builds
10-
AWS_PLUGIN_TARGET: /arduino-fwuploader/plugins/
10+
AWS_PLUGIN_TARGET: /arduino-fwuploader/plugins/uno-r4-wifi-fwuploader-plugin/
11+
AWS_REGION: "us-east-1"
1112
ARTIFACT_PREFIX: dist-
1213

1314
on:
@@ -187,9 +188,11 @@ jobs:
187188

188189
create-release:
189190
runs-on: ubuntu-latest
191+
environment: production
190192
needs: notarize-macos
191193
permissions:
192194
contents: write
195+
id-token: write # This is required for requesting the JWT
193196

194197
steps:
195198
- name: Checkout # we need package_index.template
@@ -247,12 +250,12 @@ jobs:
247250
# (all the files we need are in the DIST_DIR root)
248251
artifacts: ${{ env.DIST_DIR }}/*
249252

253+
- name: configure aws credentials
254+
uses: aws-actions/configure-aws-credentials@v4
255+
with:
256+
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
257+
role-session-name: "github_${{ env.PROJECT_NAME }}"
258+
aws-region: ${{ env.AWS_REGION }}
259+
250260
- name: Upload release files on Arduino downloads servers
251-
uses: docker://plugins/s3
252-
env:
253-
PLUGIN_SOURCE: "${{ env.DIST_DIR }}/*"
254-
PLUGIN_TARGET: ${{ env.AWS_PLUGIN_TARGET }}
255-
PLUGIN_STRIP_PREFIX: "${{ env.DIST_DIR }}/"
256-
PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }}
257-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
258-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
261+
run: aws s3 sync ${{ env.DIST_DIR }} s3://${{ secrets.DOWNLOADS_BUCKET }}${{ env.AWS_PLUGIN_TARGET }}

0 commit comments

Comments
 (0)