amplify-hosting
amplify-hosting copied to clipboard
Post Deploy Phase!
Is your feature request related to a problem? Please describe. One thing that is very much missing from amplify is a "post deploy" phase in which one can write scripts or perform operations after the full CI CD process succeeds. e.g. run a script which creates a github release for the just deployed release.
Describe the solution you'd like Add a post deployment phase to make amplify more customizable
@avner-hoffmann I'll let our product manager know about your suggestion.
One question: Would a notification work just as well? Similar to our build notifications?
@adriencg - I'm not sure I understood the question. Are you asking if amplify will need to provide another notification as for the success or failure of the post deploy phase ?
@adriencg is the postBuild phase when the 'Deploy' phase completes? @avner-hoffmann I think this might be the time to run post-deployment scripts (docs: https://docs.aws.amazon.com/amplify/latest/userguide/build-settings.html).
+1, REALLY IMPORTANT to be able to clean custom CDN and to have an hook for post-build operations
+1, the postBuild step will run before tests, and run before the actual successful deploy happens so if any of those steps fail, I've still incorrectly ran a postBuild command that I only wanted to run after the deploy step.
+1 to allowing postDeploy configuration. I find the lack of hooks b/w the various phases very limiting but adding post deploy support would be a good start.
+1 postDeploy step would be really helpful for developers run post deployment scripts(e.g. to send release emails) after actual deployment, currently thats only possible at the postBuild stage which runs before the deployment.
+1 Pleeeeese, we need this feature
@woolimi Hey :) It's probably going to take them a long time, so a workaround (although not very simple) is to use something like GitHub actions to run the Amplify build and then when it completes to run your task or suite of tasks after it completes.
+1 postDeploy step, in our case we need to invalidate other caches after the deploy. I've seen workarounds configuring alerts and checking the email that arrives there... Maybe too complex in my opinion
+1, may help us a lot!
Would love to have this functionality so that we can smoke test preview environments after they've been deployed.
+1
+1, this is super important for us where we need the ability to interact with deployed site immediately after deployment in a programmatic way. (specifically, send POST requests to the underlying webserver that will be listening once deployed)
@jasonrundell did you have any specifics you would be able to provide? With github actions, how could the action be 100% sure that the amplify deploy process has actually completed? Sure it can schedule a job to start the deploy, but the deployment takes some amount of time, and we would need to know it has complete fully before running our next task.
+1, this is super important for us where we need the ability to interact with deployed site immediately after deployment in a programmatic way. (specifically, send POST requests to the underlying webserver that will be listening once deployed)
@jasonrundell did you have any specifics you would be able to provide? With github actions, how could the action be 100% sure that the amplify deploy process has actually completed? Sure it can schedule a job to start the deploy, but the deployment takes some amount of time, and we would need to know it has complete fully before running our next task.
@ia-jortega and action like this could be what you're after:
name: My CI/CD Workflow
on:
push:
branches:
- main
jobs:
amplify_build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Run AWS Amplify Build
run: |
# Your AWS Amplify build commands go here
# For example:
# amplify init
# amplify push
next_job:
runs-on: ubuntu-latest
needs: amplify_build # This job depends on the "amplify_build" job
if: success() # This job will run only if "amplify_build" succeeds
steps:
- name: Run subsequent steps
run: |
# Your next steps go here
@jasonrundell Thank you fellow Jason, this looks promising. Before any research in the docs, it seems like the key here is the "needs" and "if" directive.
It almost reminds me of AWS Cloudformation where the "DependsOn" Directive is used for order of operations for resources dfined in one template .yml.
Will update if this works for us!
@jasonrundell This indeed seems to be a great way to solve the issue! I can see why people are having trouble finding this because it feels as if we should be trying to know about Amplify status using github action constructs, but in fact we still must use aws amplify to actually know about the status of the build/deployment job.
I cant find the SO post I got the bulk of this idea from but this is the final bash script I run in the github action that checks the amplify build status to make sure its actually done deploying b4 the next step starts:
`#!/bin/bash
echo "Deploy app $aws_app_id branch $branch_name"
JOB_ID=$(aws amplify start-job --app-id $aws_app_id --branch-name $branch_name --job-type RELEASE --query 'jobSummary.jobId' --output text)
echo "Release started" echo "Job ID is $JOB_ID"
while [[ "$(aws amplify get-job --app-id $aws_app_id --branch-name $branch_name --job-id $JOB_ID --query 'job.summary.status' --output text)" =~ ^(PENDING|RUNNING)$ ]]; do sleep 1; done
JOB_STATUS="$(aws amplify get-job --app-id $aws_app_id --branch-name $branch_name --job-id $JOB_ID --query 'job.summary.status' --output text)" echo "Job finished" echo "Job status is $JOB_STATUS" `