Amplify Branch Management #1
Workflow file for this run
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: Amplify Preview Enable | |
on: | |
create: | |
branches: | |
- 'rc/**' | |
delete: | |
branches: | |
- 'rc/**' | |
jobs: | |
deploy-on-create: | |
if: github.event_name == 'create' | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
steps: | |
- name: configure AWS credentials | |
id: creds | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: us-east-2 | |
role-to-assume: ${{ secrets.AWS_GITHUB_ACTIONS_ROLE }} | |
output-credentials: true | |
- name: Enable Amplify Preview | |
uses: mikehosmar/amplify-preview-actions@sed-replace-all | |
with: | |
branch_name: ${{ github.event.ref }} | |
amplify_command: deploy | |
env: | |
AWS_ACCESS_KEY_ID: ${{ steps.creds.outputs.aws-access-key-id }} | |
AWS_SECRET_ACCESS_KEY: ${{ steps.creds.outputs.aws-secret-access-key }} | |
AmplifyAppId: ${{ secrets.AMPLIFY_APP_ID_2 }} | |
EnablePreview: true | |
AWS_REGION: 'us-east-2' | |
cleanup-on-delete: | |
if: github.event_name == 'delete' | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
steps: | |
- name: Get ref for pull_request | |
run: | | |
echo "BRANCH_NAME=${{ github.head_ref }}" >> $GITHUB_ENV | |
if: github.event_name == 'pull_request_target' | |
- name: Get ref for delete | |
run: | | |
echo "BRANCH_NAME=${{ github.event.ref }}" >> $GITHUB_ENV | |
if: github.event_name == 'delete' | |
- name: configure AWS credentials | |
id: creds | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: us-east-2 | |
role-to-assume: ${{ secrets.AWS_GITHUB_ACTIONS_ROLE }} | |
output-credentials: true | |
- name: cleanup PR preview branch | |
uses: mikehosmar/amplify-preview-actions@sed-replace-all | |
with: | |
branch_name: ${{ env.BRANCH_NAME }} | |
amplify_command: delete | |
env: | |
AWS_ACCESS_KEY_ID: ${{ steps.creds.outputs.aws-access-key-id }} | |
AWS_SECRET_ACCESS_KEY: ${{ steps.creds.outputs.aws-secret-access-key }} | |
AmplifyAppId: ${{ secrets.AMPLIFY_APP_ID_2 }} | |
AWS_REGION: 'us-east-2' |