-
Notifications
You must be signed in to change notification settings - Fork 8.1k
refactor and mutualize netlify and aws clients for deployment #14803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for docsdocker ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
| # Disabled netlify-deploy due to flakey 502 http errors | ||
| # - name: copy static files | ||
| # if: github.event.pull_request.head.repo.fork == false | ||
| # run: docker run -v ${PWD}:/output documentation:latest cp -r /usr/share/nginx/html /output/_site | ||
| # - uses: ./.github/actions/netlify-deploy | ||
| # if: github.event.pull_request.head.repo.fork == false | ||
| # with: | ||
| # directory: _site | ||
| # netlify_token: ${{ secrets.NETLIFY_AUTH_TOKEN }} | ||
| # netlify_account_slug: ${{ secrets.NETLIFY_ACCOUNT_SLUG }} | ||
| # site_name: "${{ github.repository }}/${{ github.head_ref }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this refactoring we might enable this workflow and see if it works fine now but don't think it's necessary to have it anymore if we want to only accept pull requests from forks and disable auto publish. Step would look like this:
-
name: Netlify deploy
if: github.event.pull_request.head.repo.fork == false
uses: docker/bake-action@v2
with:
targets: netlify-deploy
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_ACCOUNT_SLUG: ${{ secrets.NETLIFY_ACCOUNT_SLUG }}
NETLIFY_SITE_NAME: ${{ github.repository }}/${{ github.head_ref }}
NETLIFY_PUBLISH_DIR: "_site"| name: clean-pr | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: | ||
| - closed | ||
|
|
||
| jobs: | ||
| remove-site-from-netlify: | ||
| name: build | ||
| runs-on: ubuntu-18.04 | ||
| netlify-remove: | ||
| runs-on: ubuntu-20.04 | ||
| if: github.event.pull_request.head.repo.fork == false | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - | ||
| name: Checkout | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.sha }} | ||
| - name: delete from netlify | ||
| uses: ./.github/actions/netlify-clean | ||
| - | ||
| name: Remove site from Netlify | ||
| uses: docker/bake-action@v2 | ||
| with: | ||
| netlify_token: ${{ secrets.NETLIFY_AUTH_TOKEN }} | ||
| site_name: "${{ github.repository }}/${{ github.head_ref }}" | ||
| targets: netlify-remove | ||
| env: | ||
| NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | ||
| NETLIFY_SITE_NAME: ${{ github.repository }}/${{ github.head_ref }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the remove published site from netlify workflow, I think we could remove it in the future if we only accept pull request from forks as we already discussed. And we could disable the auto publish feature from master branch on Netlify too, so we would not need this workflow at all:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And we could disable the auto publish feature from master branch on Netlify too, so we would not need this workflow at all:
Is that publish needed to get a preview for the "update published from master" PRs, such as #15128?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think it's needed anymore as we already deploy master branch in our publish workflow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh you mean the "published" branch in #15128. Yes it might be relevant if we don't restrict to only pull request. IMO netlify makes sense only on PR.
da25fd2 to
4631035
Compare
|
This PR is needed to put in place the lambda redirects function tested in crazy-max@d44d840 If you can PTAL @thaJeztah |
thaJeztah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall this looks good; perhaps squash the commits? (as the first commit adds the replacement code that's removed in the second one)
Left some random comments
6f1ca93 to
1674948
Compare
1674948 to
4bdb2f3
Compare
@thaJeztah Done |
4bdb2f3 to
3a33cdf
Compare
thaJeztah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
perhaps would be good to have another set of eyes on this though
f1894b4 to
962b4f2
Compare
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
962b4f2 to
3405170
Compare
Could you PTAL @StefanScherer? |
StefanScherer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you.

follow-up #14685
Refactor and mutualize our local actions in https://github.com/docker/docker.github.io/tree/master/.github/actions into a single one called
releaser. this one is containerized so it can also been tested locally withbuildx bakeand doesn't require a GitHub Runner.netlify-deployandnetlify-cleanhas been refactored and is using now the official Go library instead of the npm CLI so we are aligned with the AWS one that updates the website config and used the AWS Go SDK.update-website-confighad been refactored a bit and is now available as a subcommand ofreleaserapp:releaser aws update-config. It's also updated to a more recent AWS Go SDK. In a follow-up we should update to the AWS SDK v2.# update website config (staging) $ AWS_REGION=us-east-1 \ AWS_S3_BUCKET=docs.docker.com-stage-us-east-1 \ AWS_S3_WEBSITE_CONFIG=_website-config-docs-stage.json \ AWS_ACCESS_KEY_ID=foo \ AWS_SECRET_ACCESS_KEY=bar \ docker buildx bake aws-update-config# remove site from Netlify $ NETLIFY_AUTH_TOKEN=foo \ NETLIFY_SITE_NAME=docker/docker.github.io/master \ docker buildx bake netlify-remove