Skip to content

Add upload template logic #37

Add upload template logic

Add upload template logic #37

name: Deploy CloudFormation Templates to S3
on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
branches-ignore:
- "release/**"
- "doc/**"
env:
WORKING_DIRECTORY: templates
REGION_NAME: ap-northeast-1
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Chekcout code
uses: actions/checkout@v4
with:
fetch-depth: 0
# https://docs.github.com/ja/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#example-of-setting-an-output-parameter
- name: Check how many templates changed
id: templates
run: |
changed_templates=$(git diff HEAD^ --name-only | grep -c templates/ | grep "^M\|^A")
echo $changed_templates
echo changed_templates=$changed_templates >> "$GITHUB_OUTPUT"
# - name: configure aws credentials
# if: ${{ steps.templates.outputs.changed_templates > 0 }};
# uses: aws-actions/configure-aws-credentials@v2
# with:
# role-to-assume: arn:aws:iam::XXXXXXXXXXXX:role/github-actions-deploy-s3-bucket
# role-session-name: upload-template-dev
# aws-region: ${{ env.REGION_NAME }}
# if: steps.check_something.outcome == 'success'
- name: Upload to S3
if: ${{ steps.templates.outputs.changed_templates > 0 }};
run: |
templates=$(git diff HEAD^ --name-status | grep ${{ env.WORKING_DIRECTORY }}/ | grep "^M\|^A" | cut -f2)
echo $templates
for template in $templates; do
echo $template
done