ci: merge workflows

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2022-05-13 14:00:19 +02:00
parent 75cb114327
commit dc1a99b7b0
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
4 changed files with 111 additions and 151 deletions

View File

@ -1,50 +0,0 @@
name: deploy stage website from master branch
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-20.04
if: github.repository == 'docker/docker.github.io'
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Build
uses: docker/bake-action@v2
with:
targets: release
-
name: Upload files to S3 bucket
run: |
aws s3 sync --acl public-read _site s3://docs.docker.com-stage-us-east-1/ --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: docs.docker.com-stage-us-east-1
regionName: us-east-1
websiteConfig: _website-config-docs-stage.json
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 arn:aws:lambda:us-east-1:710015040892:function:docs-stage-cache-invalidator 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":"Successfully promoted docs-stage from master. https://docs-stage.docker.com/"}' $SLACK
env:
SLACK: ${{ secrets.SLACK_WEBHOOK }}

View File

@ -1,49 +0,0 @@
name: build docker image when PR is opened
on: pull_request
jobs:
build:
runs-on: ubuntu-20.04
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Build
uses: docker/bake-action@v2
with:
targets: release
validate:
runs-on: ubuntu-20.04
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Build
uses: docker/bake-action@v2
with:
targets: release
-
name: Check for broken links
uses: chabad360/htmlproofer@master
with:
directory: ./_site
# for available options, refer to:
# - https://github.com/gjtorikian/html-proofer
# - https://github.com/gjtorikian/html-proofer/blob/main/bin/htmlproofer
arguments: --disable-external --internal-domains="docs.docker.com,docs-stage.docker.com,localhost:4000" --file-ignore="/^./_site/engine/api/.*$/,./_site/registry/configuration/index.html" --url-ignore="/^/docker-hub/api/latest/.*$/,/^/engine/api/v.+/#.*$/,/^/glossary/.*$/"
# 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 }}"

View File

@ -1,52 +0,0 @@
name: deploy website from published branch
on:
push:
branches:
- published
jobs:
build:
runs-on: ubuntu-20.04
if: github.repository == 'docker/docker.github.io'
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Build
uses: docker/bake-action@v2
with:
targets: release
env:
JEKYLL_ENV: production
-
name: Upload files to S3 bucket
run: |
aws s3 sync --acl public-read _site s3://docs.docker.com-us-east-1/ --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: docs.docker.com-us-east-1
regionName: us-east-1
websiteConfig: _website-config-docs.json
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 arn:aws:lambda:us-east-1:710015040892:function:docs-cache-invalidator 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":"Successfully published docs. https://docs.docker.com/"}' $SLACK
env:
SLACK: ${{ secrets.SLACK_WEBHOOK }}

111
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,111 @@
name: build
on:
push:
branches:
- master
- published
pull_request:
jobs:
release:
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
-
name: Upload files to S3 bucket
if: github.event_name != 'pull_request'
run: |
aws 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 }}
validate:
runs-on: ubuntu-20.04
if: github.event_name == 'pull_request'
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Build
uses: docker/bake-action@v2
with:
targets: release
-
name: Check for broken links
uses: chabad360/htmlproofer@master
with:
directory: ./_site
# for available options, refer to:
# - https://github.com/gjtorikian/html-proofer
# - https://github.com/gjtorikian/html-proofer/blob/main/bin/htmlproofer
arguments: --disable-external --internal-domains="docs.docker.com,docs-stage.docker.com,localhost:4000" --file-ignore="/^./_site/engine/api/.*$/,./_site/registry/configuration/index.html" --url-ignore="/^/docker-hub/api/latest/.*$/,/^/engine/api/v.+/#.*$/,/^/glossary/.*$/"
# 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 }}"