Build and Publish the Production OneDocker Image #2073
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Publish the Production OneDocker Image | |
on: | |
workflow_dispatch: | |
inputs: | |
tags_csv: | |
description: A list of tags to add to the docker image in CSV form (eg. latest,1234,rc) | |
required: true | |
type: string | |
tracker_hash: | |
description: "[Internal usage] Used for tracking workflow job status within Meta infra" | |
required: false | |
type: str | |
env: | |
REGISTRY: ghcr.io | |
GH_REGISTRY_IMAGE_NAME: ghcr.io/${{ github.repository }}/prod/onedocker | |
jobs: | |
build_and_publish_image: | |
name: Build Image | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Print Tracker Hash | |
run: echo ${{ github.event.inputs.tracker_hash }} | |
- name: Set Up Docker Tags | |
id: set_up_tags | |
run: | | |
unformatted_tags=${{ inputs.tags_csv }} | |
formatted_tags=${{ env.GH_REGISTRY_IMAGE_NAME }}:${{ github.sha }},${{ env.GH_REGISTRY_IMAGE_NAME }}:${unformatted_tags/,/,${{ env.GH_REGISTRY_IMAGE_NAME }}:} | |
echo $formatted_tags | |
echo "docker_tags=$formatted_tags" >> $GITHUB_OUTPUT | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log into registry ${{ env.REGISTRY }} | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build Image | |
uses: docker/build-push-action@v3 | |
with: | |
context: docker/onedocker/prod | |
file: docker/onedocker/prod/Dockerfile.ubuntu | |
tags: ${{ steps.set_up_tags.outputs.docker_tags}} | |
push: true | |
cache-from: type=gha,scope=$GITHUB_REF_NAME-onedocker-prod | |
cache-to: type=gha,mode=max,scope=$GITHUB_REF_NAME-onedocker-prod |