Publish Latest Web App to S3 #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish Latest Web App to S3 | |
| permissions: | |
| id-token: write | |
| contents: read | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| asset_name: | |
| description: "Name of the asset to upload (e.g. www.bin)" | |
| required: true | |
| default: www.bin | |
| release: | |
| types: [published] | |
| jobs: | |
| upload: | |
| runs-on: ubuntu-latest | |
| env: | |
| REPO: Advanced-Crypto-Services/acs-esp-miner | |
| S3_BUCKET: ${{ secrets.S3_BUCKET }} | |
| AWS_REGION: ${{ secrets.AWS_REGION }} | |
| ROLE_ARN: arn:aws:iam::603187095057:role/GitHubActionsFirmwareUploadRole | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Configure AWS credentials via OIDC | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: ${{ env.ROLE_ARN }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| - name: Determine asset name | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| echo "ASSET_NAME=${{ github.event.inputs.asset_name }}" >> $GITHUB_ENV | |
| else | |
| # For release events, default to www.bin | |
| echo "ASSET_NAME=www.bin" >> $GITHUB_ENV | |
| fi | |
| - name: Print asset name (debug) | |
| run: | | |
| echo "Using asset: $ASSET_NAME" | |
| - name: Download release asset | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| # Get the latest release tag from GitHub API | |
| LATEST_TAG=$(curl -s "https://api.github.com/repos/${REPO}/releases/latest" | jq -r '.tag_name') | |
| echo "Latest release tag: $LATEST_TAG" | |
| URL="https://github.com/${REPO}/releases/download/$LATEST_TAG/$ASSET_NAME" | |
| else | |
| URL="https://github.com/${REPO}/releases/download/${{ github.event.release.tag_name }}/$ASSET_NAME" | |
| fi | |
| echo "Downloading $URL" | |
| curl -L -o "$ASSET_NAME" "$URL" | |
| - name: Upload to S3 | |
| run: | | |
| aws s3 cp "$ASSET_NAME" \ | |
| s3://$S3_BUCKET/web-app/acs-esp-miner/latest/"$ASSET_NAME" \ | |
| --acl public-read --region $AWS_REGION |