name: Build and Push Main 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: runs-on: ubuntu-latest timeout-minutes: 15 env: NONPROD_REGISTRY_USERNAME: ghdocs NONPROD_REGISTRY_NAME: ghdocs DOCKER_IMAGE_MAIN_REF: ${{ secrets.NONPROD_REGISTRY_SERVER }}/${{ github.repository }}:main steps: - name: 'Az CLI login' uses: azure/login@66d2e78565ab7af265d2b627085bc34c73ce6abb with: creds: ${{ secrets.NONPROD_AZURE_CREDENTIALS }} - name: 'Docker login' uses: azure/docker-login@81744f9799e7eaa418697cb168452a2882ae844a 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@94ab11c41e45d028884a99163086648e898eed25 - name: Check out repo uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 with: # To prevent issues with cloning early access content later persist-credentials: 'false' lfs: 'true' - name: Check out LFS objects run: git lfs checkout - if: ${{ github.repository == 'github/docs-internal' }} name: Clone early access env: DOCUBOT_REPO_PAT: ${{ secrets.DOCUBOT_REPO_PAT }} GIT_BRANCH: main run: npm install dotenv && node script/early-access/clone-for-build.js - name: 'Build and push image' uses: docker/build-push-action@a66e35b9cbcf4ad0ea91ffcaf7bbad63ad9e0229 with: context: . push: true target: ${{ fromJSON('["production", "production_early_access"]')[github.repository == 'github/docs-internal'] }} tags: ${{ env.DOCKER_IMAGE_MAIN_REF }} cache-from: type=registry,ref=${{ env.DOCKER_IMAGE_MAIN_REF }} cache-to: type=registry,mode=max,ref=${{ env.DOCKER_IMAGE_MAIN_REF }}