Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): Fix passing secrets as outputs #1125

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 19 additions & 23 deletions .github/workflows/reusable-build-iso.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,38 +179,34 @@ jobs:
compression-level: 0
overwrite: true

- name: Determine R2 Secrets
id: r2-secrets
- name: Upload ISOs and Checksum to R2 to Bluefin Bucket
Copy link
Member

@p5 p5 Apr 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can have this as one step by using GitHub Environments.
You can have a secret for "R2_ACCESS_KEY_ID" for Bluefin environment, and a separate value under the same secret name for Aurora environment.
The correct environment would be selected based on the brand name

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @p5, that sounds like a good idea! So each environment has it's own secrets and you pick that in the workflow?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. You select which environment you wish to use at the job level, and you store separate secrets for each environment.
https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#using-an-environment

You can also have repo-level secrets which are accessible from all environments

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. I think we should open an issue to do that and move the secrets to the correct environment. I don't have time to do that at the moment, is this PR OK with folks just to get ISOs building?

if: github.event_name == 'workflow_dispatch' && github.ref_name == 'main' && inputs.brand_name == 'bluefin'
shell: bash
env:
RCLONE_CONFIG_R2_TYPE: s3
RCLONE_CONFIG_R2_PROVIDER: Cloudflare
RCLONE_CONFIG_R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
RCLONE_CONFIG_R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
RCLONE_CONFIG_R2_REGION: auto
RCLONE_CONFIG_R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }}
SOURCE_DIR: ${{ steps.upload-directory.outputs.iso-upload-dir }}
run: |
if [[ ${{ inputs.brand_name }} = "bluefin" ]]; then
RCLONE_CONFIG_R2_ACCESS_KEY_ID=${{ secrets.R2_ACCESS_KEY_ID }}
RCLONE_CONFIG_R2_SECRET_ACCESS_KEY=${{ secrets.R2_SECRET_ACCESS_KEY }}
RCLONE_CONFIG_R2_ENDPOINT=${{ secrets.R2_ENDPOINT }}
BUCKET_PATH="R2:bluefin"
elif [[ ${{ inputs.brand_name }} = "aurora" ]]; then
RCLONE_CONFIG_R2_ACCESS_KEY_ID=${{ secrets.AURORA_R2_ACCESS_KEY_ID }}
RCLONE_CONFIG_R2_SECRET_ACCESS_KEY=${{ secrets.AURORA_R2_SECRET_ACCESS_KEY }}
RCLONE_CONFIG_R2_ENDPOINT=${{ secrets.AURORA_R2_ENDPOINT }}
BUCKET_PATH="R2:aurora-dl"
fi
echo "rclone-config-r2-access-key-id=${RCLONE_CONFIG_R2_ACCESS_KEY_ID}" >> $GITHUB_OUTPUT
echo "rclone-config-r2-secret-access-key=${RCLONE_CONFIG_R2_SECRET_ACCESS_KEY}" >> $GITHUB_OUTPUT
echo "rclone-config-r2-endpoint=${RCLONE_CONFIG_R2_ENDPOINT}" >> $GITHUB_OUTPUT
echo "bucket-path=${BUCKET_PATH}" >> $GITHUB_OUTPUT
sudo apt-get update
sudo apt-get install -y rclone
rclone copy $SOURCE_DIR R2:bluefin

- name: Upload ISOs and Checksum to R2
if: github.event_name == 'workflow_dispatch' && github.ref_name == 'main'
- name: Upload ISOs and Checksum to R2 to Aurora Bucket
if: github.event_name == 'workflow_dispatch' && github.ref_name == 'main' && inputs.brand_name == 'aurora'
shell: bash
env:
RCLONE_CONFIG_R2_TYPE: s3
RCLONE_CONFIG_R2_PROVIDER: Cloudflare
RCLONE_CONFIG_R2_ACCESS_KEY_ID: ${{ steps.r2-secrets.outputs.rclone-config-r2-access-key-id }}
RCLONE_CONFIG_R2_SECRET_ACCESS_KEY: ${{ steps.r2-secrets.outputs.rclone-config-r2-secret-access-key }}
RCLONE_CONFIG_R2_ACCESS_KEY_ID: ${{ secrets.AURORA_R2_ACCESS_KEY_ID }}
RCLONE_CONFIG_R2_SECRET_ACCESS_KEY: ${{ secrets.AURORA_R2_SECRET_ACCESS_KEY }}
RCLONE_CONFIG_R2_REGION: auto
RCLONE_CONFIG_R2_ENDPOINT: ${{ steps.r2-secrets.outputs.rclone-config-r2-endpoint }}
RCLONE_CONFIG_R2_ENDPOINT: ${{ secrets.AURORA_R2_ENDPOINT }}
SOURCE_DIR: ${{ steps.upload-directory.outputs.iso-upload-dir }}
run: |
sudo apt-get update
sudo apt-get install -y rclone
rclone copy $SOURCE_DIR ${{ steps.r2-secrets.outputs.bucket-path }}
rclone copy $SOURCE_DIR R2:aurora-dl
Loading