Skip to content

Commit ad9a0f7

Browse files
github: Use IAM Roles to push files on AWS S3
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 f947433 commit ad9a0f7

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

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

+13-8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ env:
1111
ARTIFACT_PREFIX: dist-
1212
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
1313
GO_VERSION: "1.17"
14+
AWS_REGION: "us-east-1"
1415

1516
on:
1617
push:
@@ -197,7 +198,11 @@ jobs:
197198

198199
create-release:
199200
runs-on: ubuntu-latest
201+
environment: production
200202
needs: notarize-macos
203+
permissions:
204+
contents: write
205+
id-token: write # This is required for requesting the JWT
201206

202207
steps:
203208
- name: Download artifact
@@ -233,12 +238,12 @@ jobs:
233238
# (all the files we need are in the DIST_DIR root)
234239
artifacts: ${{ env.DIST_DIR }}/*
235240

241+
- name: configure aws credentials
242+
uses: aws-actions/configure-aws-credentials@v4
243+
with:
244+
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
245+
role-session-name: "github_${{ env.PROJECT_NAME }}"
246+
aws-region: ${{ env.AWS_REGION }}
247+
236248
- name: Upload release files on Arduino downloads servers
237-
uses: docker://plugins/s3
238-
env:
239-
PLUGIN_SOURCE: "${{ env.DIST_DIR }}/*"
240-
PLUGIN_TARGET: ${{ env.AWS_PLUGIN_TARGET }}
241-
PLUGIN_STRIP_PREFIX: "${{ env.DIST_DIR }}/"
242-
PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }}
243-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
244-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
249+
run: aws s3 sync ${{ env.DIST_DIR }} s3://${{ secrets.DOWNLOADS_BUCKET }}${{ env.AWS_PLUGIN_TARGET }}

0 commit comments

Comments
 (0)