Skip to content

Add upload template logic #28

Add upload template logic

Add upload template logic #28

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
defaults:
run:
working-directory: ${{ env.WORKING_DIRECTORY }}
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~1 --name-only | grep -c templates/)
echo $changed_templates
echo changed_templates=$changed_templates >> "$GITHUB_OUTPUT"
- name: Upload to S3
if: ${{ steps.templates.outputs.changed_templates > 0 }};
run: |
templates=$(git diff HEAD~1 --name-status | grep ${{ env.WORKING_DIRECTORY }}/ | grep "^M\|^A" | cut -f2)
echo $templates
for template in $templates; do
echo $template
done
# - name: configure aws credentials
# if: env.TEMPLATE_CHANGED == 'true'
# run: echo 'template changed'
# uses: aws-actions/configure-aws-credentials@v2
# with:
# role-to-assume: arn:aws:iam::XXXXXXXXXXXX:role/github-actions-deploy-s3-bucket
# role-session-name: samplerolesession
# aws-region: ${{ env.REGION_NAME }}