Skip to content

Commit

Permalink
feat: add github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
RaoHai committed Sep 13, 2024
1 parent 92170fe commit 09ad53e
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions .github/workflows/aws-amplify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,35 @@ jobs:
run: npm run build
working-directory: ./client # 仅在 ./client 目录下构建 Next.js 应用程序

- name: Initialize Amplify
- name: Configure Amplify
run: amplify configure

- name: Deploy to Amplify
run: |
amplify pull --appId ${{ secrets.AMPLIFY_APP_ID }} --envName dev --yes
amplify env checkout dev
aws amplify create-branch --stage PREVIEW --app-id ${{ env.AMPLIFY_APP_ID }} --branch-name ${{ github.ref_name }} || true
echo "Checking for pending job on branch ${{ github.ref_name }}"
while true; do
jobs=$(
aws amplify list-jobs \
--app-id ${{ env.AMPLIFY_APP_ID }} \
--branch-name "${{ github.ref_name }}" \
--output "json" --no-paginate
)
pending_jobs=$(echo $jobs | jq '.jobSummaries | map(select(.status | IN("FAILED", "SUCCEED", "CANCELLED") | not))')
pending_job_count=$(echo $pending_jobs | jq 'length')
echo "Pending Jobs: $pending_job_count"
- name: Deploy to Amplify
env:
AMPLIFY_APP_ID: ${{ env.AMPLIFY_APP_ID }}
AMPLIFY_BRANCH: dev
run: amplify push --y
if [ "$pending_job_count" -gt 0 ]; then
echo "$pending_job_count Pending Job(s) found on branch ${{ github.ref_name }}. Waiting..."
sleep 10
else
echo "All Pending Jobs done... Proceeding"
break
fi
done
echo "Starting Amplify Job"
aws amplify start-job \
--app-id ${{ env.AMPLIFY_APP_ID }} \
--branch-name ${{ github.ref_name }} \
--job-type RELEASE

0 comments on commit 09ad53e

Please sign in to comment.