mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Get AWS regions and SPB_ENVIRONMENT from metadata endpoint
This commit is contained in:
parent
e60f6a4bdf
commit
e0c876b985
1 changed files with 14 additions and 3 deletions
17
.github/actions/cache/action.yml
vendored
17
.github/actions/cache/action.yml
vendored
|
@ -67,18 +67,29 @@ runs:
|
|||
restore-keys: ${{ env.GHA_CACHE_RESTORE_KEYS }}
|
||||
upload-chunk-size: ${{ env.GHA_CACHE_UPLOAD_CHUNK_SIZE }}
|
||||
|
||||
- name: Get Salt Project GitHub Actions Bot Environment
|
||||
if: ${{ env.USE_S3_CACHE == 'true' }}
|
||||
shell: bash
|
||||
run: |
|
||||
TOKEN=$(curl -sS -f -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 30")
|
||||
SPB_ENVIRONMENT=$(curl -sS -f -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/tags/instance/spb:environment)
|
||||
echo "SPB_ENVIRONMENT=$SPB_ENVIRONMENT" | tee -a "$GITHUB_ENV"
|
||||
REGION=$(curl -sS -f -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/placement/region)
|
||||
echo "GHA_CACHE_AWS_REGION=$REGION" | tee -a "$GITHUB_ENV"
|
||||
|
||||
- name: Configure AWS Credentials to access cache bucket
|
||||
id: creds
|
||||
if: ${{ env.USE_S3_CACHE == 'true' }}
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
aws-region: us-west-2
|
||||
aws-region: ${{ env.GHA_CACHE_AWS_REGION }}
|
||||
|
||||
- name: Cache Provided Path (S3)
|
||||
if: ${{ env.USE_S3_CACHE == 'true' }}
|
||||
id: s3-cache
|
||||
env:
|
||||
RUNS_ON_S3_BUCKET_CACHE: "salt-project-test-salt-github-actions-s3-cache"
|
||||
AWS_REGION: 'us-west-2'
|
||||
AWS_REGION: ${{ env.GHA_CACHE_AWS_REGION }}
|
||||
RUNS_ON_S3_BUCKET_CACHE: salt-project-${{ env.SPB_ENVIRONMENT}}-salt-github-actions-s3-cache
|
||||
uses: runs-on/cache@v4
|
||||
with:
|
||||
path: ${{ env.GHA_CACHE_PATH }}
|
||||
|
|
Loading…
Add table
Reference in a new issue