mirror of
https://github.com/docker/docs.git
synced 2026-03-27 14:28:47 +07:00
ci: split build and publish workflows and set up cache
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
68
.github/workflows/build.yml
vendored
68
.github/workflows/build.yml
vendored
@@ -2,36 +2,15 @@ name: build
|
||||
|
||||
on:
|
||||
push:
|
||||
# needs push event on default branch otherwise cache is evicted when pull request is merged
|
||||
branches:
|
||||
- master
|
||||
- published
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
release:
|
||||
build:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
-
|
||||
name: Prepare
|
||||
run: |
|
||||
JEKYLL_ENV=development
|
||||
if [ "${{ github.ref }}" = "refs/heads/master" ]; then
|
||||
DOCS_S3_HOST="docs.docker.com-stage-us-east-1"
|
||||
DOCS_AWS_LAMBDA="arn:aws:lambda:us-east-1:710015040892:function:docs-stage-cache-invalidator"
|
||||
DOCS_SLACK_MSG="Successfully promoted docs-stage from master. https://docs-stage.docker.com/"
|
||||
DOCS_WEBCONFIG="_website-config-docs-stage.json"
|
||||
elif [ "${{ github.ref }}" = "refs/heads/published" ]; then
|
||||
JEKYLL_ENV=production
|
||||
DOCS_S3_HOST="docs.docker.com-us-east-1"
|
||||
DOCS_AWS_LAMBDA="arn:aws:lambda:us-east-1:710015040892:function:docs-cache-invalidator"
|
||||
DOCS_SLACK_MSG="Successfully published docs. https://docs.docker.com/"
|
||||
DOCS_WEBCONFIG="_website-config-docs.json"
|
||||
fi
|
||||
echo "JEKYLL_ENV=$JEKYLL_ENV" >> $GITHUB_ENV
|
||||
echo "DOCS_S3_HOST=$DOCS_S3_HOST" >> $GITHUB_ENV
|
||||
echo "DOCS_AWS_LAMBDA=$DOCS_AWS_LAMBDA" >> $GITHUB_ENV
|
||||
echo "DOCS_SLACK_MSG=$DOCS_SLACK_MSG" >> $GITHUB_ENV
|
||||
echo "DOCS_WEBCONFIG=$DOCS_WEBCONFIG" >> $GITHUB_ENV
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
@@ -43,51 +22,28 @@ jobs:
|
||||
uses: docker/bake-action@v2
|
||||
with:
|
||||
targets: release
|
||||
-
|
||||
name: Upload files to S3 bucket
|
||||
if: github.event_name != 'pull_request'
|
||||
run: |
|
||||
aws --region us-east-1 s3 sync --acl public-read _site s3://${{ env.DOCS_S3_HOST }}/ --delete
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
-
|
||||
name: Update S3 website config
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: ./.github/actions/update-website-config
|
||||
with:
|
||||
bucketName: ${{ env.DOCS_S3_HOST }}
|
||||
regionName: us-east-1
|
||||
websiteConfig: ${{ env.DOCS_WEBCONFIG }}
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
-
|
||||
name: Invalidate docs website cache
|
||||
if: github.event_name != 'pull_request'
|
||||
run: |
|
||||
aws --region us-east-1 lambda invoke --function-name ${{ env.DOCS_AWS_LAMBDA }} response.json
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
-
|
||||
name: Send Slack notification
|
||||
if: github.event_name != 'pull_request'
|
||||
run: |
|
||||
curl -X POST -H 'Content-type: application/json' --data '{"text":"${{ env.DOCS_SLACK_MSG }}"}' ${{ secrets.SLACK_WEBHOOK }}
|
||||
set: |
|
||||
*.cache-from=type=gha,scope=build
|
||||
*.cache-to=type=gha,scope=build,mode=max
|
||||
|
||||
validate:
|
||||
runs-on: ubuntu-20.04
|
||||
if: github.event_name == 'pull_request'
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
-
|
||||
name: Check for broken links
|
||||
uses: docker/bake-action@v2
|
||||
with:
|
||||
targets: htmlproofer
|
||||
set: |
|
||||
*.cache-from=type=gha,scope=build
|
||||
*.cache-from=type=gha,scope=validate
|
||||
*.cache-to=type=gha,scope=validate,mode=max
|
||||
|
||||
# Disabled netlify-deploy due to flakey 502 http errors
|
||||
# - name: copy static files
|
||||
|
||||
75
.github/workflows/publish.yml
vendored
Normal file
75
.github/workflows/publish.yml
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
name: publish
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- published
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
-
|
||||
name: Prepare
|
||||
run: |
|
||||
JEKYLL_ENV=development
|
||||
if [ "${{ github.ref }}" = "refs/heads/master" ]; then
|
||||
DOCS_S3_HOST="docs.docker.com-stage-us-east-1"
|
||||
DOCS_AWS_LAMBDA="arn:aws:lambda:us-east-1:710015040892:function:docs-stage-cache-invalidator"
|
||||
DOCS_SLACK_MSG="Successfully promoted docs-stage from master. https://docs-stage.docker.com/"
|
||||
DOCS_WEBCONFIG="_website-config-docs-stage.json"
|
||||
elif [ "${{ github.ref }}" = "refs/heads/published" ]; then
|
||||
JEKYLL_ENV=production
|
||||
DOCS_S3_HOST="docs.docker.com-us-east-1"
|
||||
DOCS_AWS_LAMBDA="arn:aws:lambda:us-east-1:710015040892:function:docs-cache-invalidator"
|
||||
DOCS_SLACK_MSG="Successfully published docs. https://docs.docker.com/"
|
||||
DOCS_WEBCONFIG="_website-config-docs.json"
|
||||
fi
|
||||
echo "JEKYLL_ENV=$JEKYLL_ENV" >> $GITHUB_ENV
|
||||
echo "DOCS_S3_HOST=$DOCS_S3_HOST" >> $GITHUB_ENV
|
||||
echo "DOCS_AWS_LAMBDA=$DOCS_AWS_LAMBDA" >> $GITHUB_ENV
|
||||
echo "DOCS_SLACK_MSG=$DOCS_SLACK_MSG" >> $GITHUB_ENV
|
||||
echo "DOCS_WEBCONFIG=$DOCS_WEBCONFIG" >> $GITHUB_ENV
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
-
|
||||
name: Build
|
||||
uses: docker/bake-action@v2
|
||||
with:
|
||||
targets: release
|
||||
set: |
|
||||
*.cache-from=type=gha,scope=publish
|
||||
*.cache-to=type=gha,scope=publish,mode=max
|
||||
-
|
||||
name: Upload files to S3 bucket
|
||||
run: |
|
||||
aws --region us-east-1 s3 sync --acl public-read _site s3://${{ env.DOCS_S3_HOST }}/ --delete
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
-
|
||||
name: Update S3 website config
|
||||
uses: ./.github/actions/update-website-config
|
||||
with:
|
||||
bucketName: ${{ env.DOCS_S3_HOST }}
|
||||
regionName: us-east-1
|
||||
websiteConfig: ${{ env.DOCS_WEBCONFIG }}
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
-
|
||||
name: Invalidate docs website cache
|
||||
run: |
|
||||
aws --region us-east-1 lambda invoke --function-name ${{ env.DOCS_AWS_LAMBDA }} response.json
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
-
|
||||
name: Send Slack notification
|
||||
run: |
|
||||
curl -X POST -H 'Content-type: application/json' --data '{"text":"${{ env.DOCS_SLACK_MSG }}"}' ${{ secrets.SLACK_WEBHOOK }}
|
||||
Reference in New Issue
Block a user