Skip to content

Commit

Permalink
Merge pull request #203 from arduino/iam-roles
Browse files Browse the repository at this point in the history
github: Use IAM Roles to push files on AWS S3
  • Loading branch information
alessio-perugini authored Dec 13, 2024
2 parents 1a68dfb + 9af805a commit 1724e56
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
31 changes: 21 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ on:
- main

env:
# As defined by the Taskfile's PROJECT_NAME variable
PROJECT_NAME: arduino-language-server
ARTIFACT_PREFIX: dist-
AWS_REGION: "us-east-1"
# The project's folder on Arduino's download server for uploading builds
AWS_PLUGIN_TARGET: /arduino-language-server/nightly/
# As defined by the Taskfile's DIST_DIR variable
DIST_DIR: dist

jobs:

Expand Down Expand Up @@ -65,20 +72,24 @@ jobs:
needs: build
if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main')
runs-on: ubuntu-latest
environment: production
permissions:
contents: write
id-token: write # This is required for requesting the JWT
steps:
- name: Download Workflow Artifact [GitHub Actions]
uses: actions/download-artifact@v4
with:
pattern: ${{ env.ARTIFACT_PREFIX }}*
merge-multiple: true
path: build-artifacts
path: ${{ env.DIST_DIR }}

- name: Publish Nightly [S3]
uses: docker://plugins/s3
env:
PLUGIN_SOURCE: "build-artifacts/*"
PLUGIN_TARGET: "/arduino-language-server/nightly"
PLUGIN_STRIP_PREFIX: "build-artifacts/"
PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-session-name: "github_${{ env.PROJECT_NAME }}"
aws-region: ${{ env.AWS_REGION }}

- name: Upload release files on Arduino downloads servers
run: aws s3 sync ${{ env.DIST_DIR }} s3://${{ secrets.DOWNLOADS_BUCKET }}${{ env.AWS_PLUGIN_TARGET }}
21 changes: 13 additions & 8 deletions .github/workflows/release-go-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ env:
DIST_DIR: dist
# The project's folder on Arduino's download server for uploading builds
AWS_PLUGIN_TARGET: /arduino-language-server/
AWS_REGION: "us-east-1"
ARTIFACT_PREFIX: dist-

on:
Expand Down Expand Up @@ -189,7 +190,11 @@ jobs:

create-release:
runs-on: ubuntu-latest
environment: production
needs: notarize-macos
permissions:
contents: write
id-token: write # This is required for requesting the JWT

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

- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-session-name: "github_${{ env.PROJECT_NAME }}"
aws-region: ${{ env.AWS_REGION }}

- name: Upload release files on Arduino downloads servers
uses: docker://plugins/s3
env:
PLUGIN_SOURCE: "${{ env.DIST_DIR }}/*"
PLUGIN_TARGET: ${{ env.AWS_PLUGIN_TARGET }}
PLUGIN_STRIP_PREFIX: "${{ env.DIST_DIR }}/"
PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: aws s3 sync ${{ env.DIST_DIR }} s3://${{ secrets.DOWNLOADS_BUCKET }}${{ env.AWS_PLUGIN_TARGET }}

0 comments on commit 1724e56

Please sign in to comment.