Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 12 additions & 56 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
75 changes: 75 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: publish

on:
push:
branches:
- master
- published

jobs:
publish:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps in a follow-up we should consider adding a check-for-broken-links check in this workflow as well, to make sure no links are broken before publishing

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 }}