79 lines
3.0 KiB
YAML
79 lines
3.0 KiB
YAML
name: Build and Push Main Preview Env Docker Cache
|
|
|
|
# **What it does**: Builds and pushes the `main` Docker cache image
|
|
# **Why we have it**: It allows PRs using the registry cache to pull a pre-built image, which should speed up the build
|
|
# **Who does it impact**: All contributors.
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
# This allows a subsequently queued workflow run to take priority over
|
|
# previously queued runs and interrupt currently executing runs
|
|
concurrency:
|
|
group: '${{ github.workflow }}'
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build-and-push-nonprod-cache:
|
|
if: ${{ github.repository == 'github/docs-internal' || github.repository == 'github/docs' }}
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 15
|
|
env:
|
|
ENABLE_EARLY_ACCESS: ${{ github.repository == 'github/docs-internal' }}
|
|
DOCKER_IMAGE_CACHE_REF: ${{ secrets.NONPROD_REGISTRY_SERVER }}/${{ github.repository }}:main-preview
|
|
NONPROD_REGISTRY_USERNAME: ${{ fromJSON('["ghdocs", "ghdocsinternal"]')[github.repository == 'github/docs-internal'] }}
|
|
|
|
steps:
|
|
- name: 'Az CLI login'
|
|
uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # pin @v1.4.6
|
|
with:
|
|
creds: ${{ secrets.NONPROD_AZURE_CREDENTIALS }}
|
|
|
|
- name: 'Docker login'
|
|
uses: azure/docker-login@83efeb77770c98b620c73055fbb59b2847e17dc0
|
|
with:
|
|
login-server: ${{ secrets.NONPROD_REGISTRY_SERVER }}
|
|
username: ${{ env.NONPROD_REGISTRY_USERNAME }}
|
|
password: ${{ secrets.NONPROD_REGISTRY_PASSWORD }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@95cb08cb2672c73d4ffd2f422e6d11953d2a9c70
|
|
|
|
- name: Check out repo
|
|
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
|
|
with:
|
|
# To prevent issues with cloning early access content later
|
|
persist-credentials: 'false'
|
|
|
|
- if: ${{ env.ENABLE_EARLY_ACCESS }}
|
|
name: Clone docs-early-access
|
|
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
|
|
with:
|
|
repository: github/docs-early-access
|
|
token: ${{ secrets.DOCUBOT_REPO_PAT }}
|
|
path: docs-early-access
|
|
ref: main
|
|
|
|
- if: ${{ env.ENABLE_EARLY_ACCESS }}
|
|
name: Merge docs-early-access repo's folders
|
|
run: .github/actions-scripts/merge-early-access.sh
|
|
|
|
# In addition to making the final image smaller, we also save time by not sending unnecessary files to the docker build context
|
|
- name: 'Prune for preview env'
|
|
run: .github/actions-scripts/prune-for-preview-env.sh
|
|
|
|
- name: 'Build and push image'
|
|
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
|
|
with:
|
|
context: .
|
|
push: true
|
|
target: preview
|
|
tags: ${{ env.DOCKER_IMAGE_CACHE_REF }}
|
|
cache-from: type=registry,ref=${{ env.DOCKER_IMAGE_CACHE_REF }}
|
|
cache-to: type=registry,mode=max,ref=${{ env.DOCKER_IMAGE_CACHE_REF }}
|