Skip to content

Commit 7bf9995

Browse files
added generation of zip files (#14)
* added generation of zip files
1 parent 1d71e2b commit 7bf9995

File tree

1 file changed

+50
-3
lines changed

1 file changed

+50
-3
lines changed

.github/workflows/githubaction-comment-apply.yml

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@ on:
2828
type: string
2929
default: "."
3030

31-
3231
jobs:
3332
check-changes:
3433
runs-on: ubuntu-latest
3534
outputs:
3635
stack_changed: ${{ steps.filter.outputs.stack_changed }}
3736
steps:
3837
- name: Checkout
39-
uses: actions/checkout@v2
38+
uses: actions/checkout@v4
4039
with:
4140
fetch-depth: 0 # Important to fetch all history for branches
4241
- name: Check for changes in the stack based on input
@@ -141,6 +140,7 @@ jobs:
141140
TERRAFORM_ACTIONS_GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
142141
GITHUB_APP_ID: ${{ secrets.TERRAFORM_GITHUB_ACTION_APP_ID }}
143142
GITHUB_APP_PEM_FILE: ${{ secrets.TERRAFORM_GITHUB_ACTION_PRIVATE_KEY }}
143+
144144
- name: terraform fmt ${{ inputs.stack }}
145145
uses: dflook/terraform-fmt-check@v1
146146
with:
@@ -169,6 +169,47 @@ jobs:
169169
rm -rf .terraform .terraform.lock.hcl
170170
tofu init -upgrade
171171
# Build or change infrastructure according to Tofu configuration files
172+
173+
- name: Zip Lambda Directories
174+
run: |
175+
cd ${{ inputs.stack }}
176+
find .terraform/modules -mindepth 2 -maxdepth 2 -type d -name 'lambda' | while read lambda_dir; do
177+
module_dir=$(dirname "$lambda_dir")
178+
zip_name="$module_dir/lambda.zip"
179+
temp_zip_name="/tmp/$(basename "$module_dir").zip"
180+
181+
echo "Processing directory $lambda_dir"
182+
echo "Target zip file: $zip_name"
183+
184+
# Create a temporary zip file in /tmp directory
185+
cd "$lambda_dir"
186+
zip -r "$temp_zip_name" ./*
187+
cd - > /dev/null
188+
189+
# Move the temporary zip file to the desired location
190+
mv "$temp_zip_name" "$zip_name"
191+
192+
echo "Zipped contents of $lambda_dir to $zip_name"
193+
done
194+
195+
# Verify contents of each module directory after zipping
196+
find .terraform/modules -mindepth 1 -maxdepth 1 -type d | while read dir; do
197+
echo "Contents of $dir:"
198+
ls -l "$dir"
199+
done
200+
201+
- name: Verify Lambda ZIPs Contents
202+
run: |
203+
cd ${{ inputs.stack }}
204+
for zip in $(find .terraform/modules -type f -name 'lambda.zip'); do
205+
echo "Checking contents of $zip:"
206+
unzip -l "$zip"
207+
done
208+
209+
- name: Verify Lambda ZIPs
210+
run: |
211+
find ${{ inputs.stack }}/.terraform/modules -type f -name 'lambda.zip' -exec ls -l {} \;
212+
172213
- name: Tofu Apply
173214
id: apply
174215
continue-on-error: true
@@ -251,6 +292,12 @@ jobs:
251292
-H "Content-Type: application/json" \
252293
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
253294
-d @comment3.txt
295+
296+
# Cleanup lambda.zip files
297+
# - name: Cleanup lambda.zip Files
298+
# run: |
299+
# find . -type f -name 'lambda.zip' -delete
300+
254301

255302
logging:
256303
name: 'Save logs'
@@ -282,4 +329,4 @@ jobs:
282329
# Upload it to s3
283330
aws s3 cp $LOG_FILENAME s3://${{ inputs.s3bucketName }}/logs/Apply/
284331
env:
285-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
332+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)