aws-amplify / amplify-hosting

AWS Amplify Hosting provides a Git-based workflow for deploying and hosting fullstack serverless web applications.
https://aws.amazon.com/amplify/hosting/
Apache License 2.0
450 stars 113 forks source link

GitLab previews #657

Open steinybot opened 4 years ago

steinybot commented 4 years ago

Please describe which feature you have a question about?

I have configured previews for my app where the code is hosted in a GitLab repository. AWS Amplify does detect my Merge Requests and starts a build but it does not add any kind of status to the Merge Request in GitLab. Is there any way to do this? I'm assuming that it is not possible to work with the GitLab Pipelines feature but even a simple comment with the URLs to the build and the frontend would be nice.

Provide additional details

swaminator commented 4 years ago

@steinybot just to be clear on your requirement - you want the ability to post to a PR on the status of a build with a link to the frontend URL

steinybot commented 4 years ago

The requirement is to be able to go to the frontend preview from a GitLab merge request. A bonus is to have also be able to see the current build status from the GitLab merge request. Another way of putting it is to have feature parity with the GitHub integration.

willianjusten commented 3 years ago

Any news about that? I really want to use Amplify Previews + Gitlab but as for now, it's "unusable"...

mathvbarone commented 3 years ago

Same here!

snowakdc commented 3 years ago

Any updates here? That'd be really useful

SimonyanG commented 2 years ago

Guys this is an important feature, any news?

RobertAron commented 2 years ago

Ended up with a DIY method in gitlab CI.

The preview URL is based on the GitLab merge request ID and Amplify App ID. You can curl GitLab to make a comment with the link manually. To use this

stages:
  - preview

preview:
  stage: preview
  only:
    - merge_requests
  script:
    - |
      curl \
        --data-urlencode "body=## After build preview will 🚀[be here!](https://pr-${CI_MERGE_REQUEST_IID}.YOUR_AMPLIFY_APP_ID.amplifyapp.com/)" \
        --request POST \
        --header "PRIVATE-TOKEN: ${GITLAB_ACCESS_TOKEN}" \
        "https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/merge_requests/${CI_MERGE_REQUEST_IID}/discussions"
aspiers commented 2 years ago

Thanks for that @RobertAron! In case anyone else is wondering how to try the above hint, the Amplify app id is the string after the / in the App ARN, obtained by going to the app's general settings. It is also the subdomain of amplifyapp.com embedded in the deployment URLs.

aspiers commented 2 years ago

Also, CI_PROJECT_ID can be found by going to the project page > View Source > search for project_id in the HTML source, although this is only needed during manual testing of the curl command - it's automatically defined during the pipeline.

aspiers commented 2 years ago

One more tip - I found that the above YAML worked great, but in contrast it didn't if instead I added the curl command to an existing CI job. In that case for some reason it wasn't considered a merge request pipeline, therefore predefined variables for merge request pipelines (in particular CI_MERGE_REQUEST_IID) weren't defined.

GiancarlosIO commented 1 month ago

We are trying to migrate from vercel to amplify and just found this... which somehow is a blocker us 😢