ManualPushToCodeCommit #14
This file contains 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: ManualPushToCodeCommit | |
on: workflow_dispatch | |
jobs: | |
PushToCodeCommit: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{secrets.AMI_MIRROR_ROLE}} | |
aws-region: us-west-2 | |
- name: Delete shinkansen branch on codecommit repository | |
run: | | |
aws codecommit delete-branch --repository-name amazon-ecs-ami-mirror --branch-name shinkansen | |
- name: Sleeping for 30 seconds after CodeCommit branch deletion and before recreating it | |
run: | | |
sleep 30 | |
- name: Configure prereqs | |
run: | | |
git config --global user.name "Github Action" | |
git config --global user.email "[email protected]" | |
pip install git-remote-codecommit | |
- name: Mirror to shinkansen branch on codecommit repository | |
run: | | |
date=$(date '+%Y%m%d') | |
git clone --single-branch --branch main https://github.com/aws/amazon-ecs-ami ecsAmiGithub | |
git clone codecommit::us-west-2://amazon-ecs-ami-mirror ecsAmiCodeCommit | |
cp ecsAmiCodeCommit/Config ecsAmiGithub/ | |
cd ecsAmiGithub | |
git add Config | |
git commit -m "Release ${date}" | |
git remote add codecommit codecommit::us-west-2://amazon-ecs-ami-mirror | |
git push codecommit main:shinkansen | |
MetricPublish: | |
needs: [PushToCodeCommit] | |
if: ${{ always() }} | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{secrets.AMI_MIRROR_ROLE}} | |
aws-region: us-west-2 | |
- name: Success | |
if: ${{ needs.PushToCodeCommit.result == 'success' }} | |
run: aws cloudwatch put-metric-data --metric-name EcsAmiGithubActionStatus --namespace ECSAMIRelease --value 1 |