Add upload template logic #34
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: 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: 1 | |
# https://docs.github.com/ja/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#example-of-setting-an-output-parameter | |
# changed_templates=$(git diff HEAD^ --name-only | grep -c templates/) | |
- name: Check how many templates changed | |
id: templates | |
run: | | |
changed_templates=$(git diff --name-only | grep -c templates/) | |
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 |