Skip to content

Creating gf gold disk workflow #1479

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
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
93 changes: 93 additions & 0 deletions .github/workflows/update-gold-disk-gf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Update Gold Disk

on:
workflow_dispatch:
inputs:
branch:
required: false
type: string
description: "Branch to run this workflow on (defaults to main)"
environment:
required: false
type: choice
options:
- test
- prod
description: "Deployment environment (defaults to dev on pull request)"

jobs:
update-gold-disk:
runs-on: codebuild-ab2d-${{github.run_id}}-${{github.run_attempt}}
permissions:
contents: read
id-token: write
steps:
- name: Get AWS params
uses: cmsgov/ab2d-bcda-dpc-platform/actions/aws-params-env-action@main
env:
AWS_REGION: ${{ vars.AWS_REGION }}
with:
params: |
OPS_GITHUB_TOKEN=/ci/github/token

- name: Determine Branch and Environment
run: |
echo "ENVIRONMENT=${{ github.event.inputs.environment || 'test' }}" >> $GITHUB_ENV
echo "BRANCH=${{ github.event.inputs.branch || 'main' }}" >> $GITHUB_ENV


- name: Checkout AB2D-Ops Repository
uses: actions/checkout@v4
with:
repository: 'cmsgov/ab2d-ops'
token: ${{ env.OPS_GITHUB_TOKEN }}
ref: ${{ env.BRANCH }}

- name: Fetch all branches
run: git fetch --all

- name: Set PARENT_ENV
run: |
aws sts get-caller-identity
case "${{ env.ENVIRONMENT }}" in
test) echo "PARENT_ENV=ab2d-east-test" >> $GITHUB_ENV ;;
prod) echo "PARENT_ENV=ab2d-east-prod" >> $GITHUB_ENV ;;
*) echo "Invalid environment: $ENVIRONMENT" && exit 1 ;;
esac

- name: Assume role in AB2D account for this environment
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
env:
ACCOUNT: ${{ inputs.environment == 'test' && 'non_prod' || inputs.environment }}
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: arn:aws:iam::${{ secrets[format('{0}_ACCOUNT', env.ACCOUNT)] }}:role/delegatedadmin/developer/ab2d-${{ inputs.environment }}-github-actions
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this be using either NON_PROD_ACCOUNT or PROD_ACOUNT?


- name: Set AWS_ACCOUNT_NUMBER from current credentials
run: |
ACCOUNT_ID=$(aws sts get-caller-identity --query "Account" --output text)
echo "AWS_ACCOUNT_NUMBER=$ACCOUNT_ID" >> $GITHUB_ENV

- name: Setup `packer`
uses: hashicorp/setup-packer@main
id: setup
with:
version: 1.10.0

- name: Symlink packer to /usr/bin if not already linked
run: |
if [ ! -f /usr/bin/packer ]; then
sudo ln -s "$(which packer)" /usr/bin/packer
else
echo "✅ /usr/bin/packer already exists, skipping symlink."
fi


- name: Run Update Gold Disk Script
run: |
chmod +x scripts/deployment/update-gold-disk.sh
scripts/deployment/update-gold-disk-gf.sh --cms_env $PARENT_ENV --cloud_tamer false
env:
AWS_ACCOUNT_NUMBER: ${{ env.AWS_ACCOUNT_NUMBER }}
CLOUD_TAMER: false