|
| 1 | +name: Build and Push Main Docker Cache |
| 2 | + |
| 3 | +# **What it does**: Builds and pushes the `main` Docker cache image |
| 4 | +# **Why we have it**: It allows PRs using the registry cache to pull a pre-built image, which should speed up the build |
| 5 | +# **Who does it impact**: All contributors. |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + |
| 15 | +# This allows a subsequently queued workflow run to take priority over |
| 16 | +# previously queued runs and interrupt currently executing runs |
| 17 | +concurrency: |
| 18 | + group: '${{ github.workflow }}' |
| 19 | + cancel-in-progress: true |
| 20 | + |
| 21 | +jobs: |
| 22 | + build-and-push-nonprod-cache: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + timeout-minutes: 15 |
| 25 | + env: |
| 26 | + NONPROD_REGISTRY_USERNAME: ghdocs |
| 27 | + NONPROD_REGISTRY_NAME: ghdocs |
| 28 | + DOCKER_IMAGE_MAIN_REF: ${{ secrets.NONPROD_REGISTRY_SERVER }}/${{ github.repository }}:main |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: 'Az CLI login' |
| 32 | + uses: azure/login@66d2e78565ab7af265d2b627085bc34c73ce6abb |
| 33 | + with: |
| 34 | + creds: ${{ secrets.NONPROD_AZURE_CREDENTIALS }} |
| 35 | + |
| 36 | + - name: 'Docker login' |
| 37 | + uses: azure/docker-login@81744f9799e7eaa418697cb168452a2882ae844a |
| 38 | + with: |
| 39 | + login-server: ${{ secrets.NONPROD_REGISTRY_SERVER }} |
| 40 | + username: ${{ env.NONPROD_REGISTRY_USERNAME }} |
| 41 | + password: ${{ secrets.NONPROD_REGISTRY_PASSWORD }} |
| 42 | + |
| 43 | + - name: Set up Docker Buildx |
| 44 | + uses: docker/setup-buildx-action@94ab11c41e45d028884a99163086648e898eed25 |
| 45 | + |
| 46 | + - name: Check out repo |
| 47 | + uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 |
| 48 | + with: |
| 49 | + # To prevent issues with cloning early access content later |
| 50 | + persist-credentials: 'false' |
| 51 | + lfs: 'true' |
| 52 | + |
| 53 | + - name: Check out LFS objects |
| 54 | + run: git lfs checkout |
| 55 | + |
| 56 | + - if: ${{ github.repository == 'github/docs-internal' }} |
| 57 | + name: Clone early access |
| 58 | + env: |
| 59 | + DOCUBOT_REPO_PAT: ${{ secrets.DOCUBOT_REPO_PAT }} |
| 60 | + GIT_BRANCH: main |
| 61 | + run: npm install dotenv && node script/early-access/clone-for-build.js |
| 62 | + |
| 63 | + - name: 'Build and push image' |
| 64 | + uses: docker/build-push-action@a66e35b9cbcf4ad0ea91ffcaf7bbad63ad9e0229 |
| 65 | + with: |
| 66 | + context: . |
| 67 | + push: true |
| 68 | + target: ${{ fromJSON('["production", "production_early_access"]')[github.repository == 'github/docs-internal'] }} |
| 69 | + tags: ${{ env.DOCKER_IMAGE_MAIN_REF }} |
| 70 | + cache-from: type=registry,ref=${{ env.DOCKER_IMAGE_MAIN_REF }} |
| 71 | + cache-to: type=registry,mode=max,ref=${{ env.DOCKER_IMAGE_MAIN_REF }} |
0 commit comments