Manual - Build, Test, and Push #119
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
on: | |
workflow_dispatch: | |
inputs: | |
branch: | |
description: "Branch to build off." | |
default: "main" | |
type: choice | |
options: | |
- main | |
- dev | |
- dev-rspm | |
product: | |
description: "The product/path to build." | |
required: true | |
type: choice | |
options: | |
- connect | |
- connect-content-init | |
- package-manager | |
- r-session-complete | |
- workbench | |
- workbench-for-google-cloud-workstations | |
- workbench-for-microsoft-azure-ml | |
type: | |
description: "The type of image being built." | |
required: false | |
default: "preview" | |
type: choice | |
options: | |
- preview | |
- daily | |
- release | |
version: | |
description: "The version to build. Use 'auto' to target the latest build." | |
required: false | |
default: "auto" | |
type: string | |
push: | |
description: "Flag to push the image after build." | |
required: false | |
default: false | |
type: boolean | |
name: Manual - Build, Test, and Push | |
jobs: | |
setup: | |
name: Setup | |
runs-on: ubuntu-latest | |
outputs: | |
GIT_SHA: ${{ steps.get-git-sha.outputs.GIT_SHA }} | |
BAKE_FILE: ${{ steps.bake-file.outputs.BAKE_FILE }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get commit SHA | |
id: get-git-sha | |
run: | | |
GIT_SHA=$(git rev-parse --short HEAD) | |
echo "Setting GIT_SHA=$GIT_SHA" | |
echo "GIT_SHA=$GIT_SHA" >> $GITHUB_OUTPUT | |
- name: Set BAKE_FILE | |
id: bake-file | |
run: | | |
if [[ "${{ inputs.type }}" == "release" ]]; then | |
BAKE_FILE="docker-bake.hcl" | |
else | |
BAKE_FILE="docker-bake.preview.hcl" | |
fi | |
echo "Using $BAKE_FILE" | |
echo "BAKE_FILE=$BAKE_FILE" >> $GITHUB_OUTPUT | |
build: | |
needs: [setup] | |
runs-on: ubuntu-latest-4x | |
name: manual-build | |
permissions: | |
contents: read | |
packages: write | |
env: | |
GIT_SHA: ${{ needs.setup.outputs.GIT_SHA }} | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.branch }} | |
- name: Set up Just | |
uses: extractions/setup-just@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Install Python dependencies | |
run: | | |
pip install requests | |
- name: Get Target | |
id: get-target | |
shell: bash | |
run: | | |
# Append suffix if necessary | |
target="${{ inputs.product }}" | |
if [[ "${{ inputs.type }}" != "release" ]]; then | |
target="${{ inputs.product }}-${{ inputs.type }}" | |
fi | |
echo "Setting TARGET=$target" | |
echo "TARGET=$target" >> $GITHUB_OUTPUT | |
- name: Get Version | |
id: get-version | |
shell: bash | |
run: | | |
# Determine how to set the version | |
if [[ "${{ inputs.version }}" == "auto" ]]; then | |
VERSION=`just -f ci.Justfile get-version ${{ inputs.product }} --type=${{ inputs.type }} --local` | |
else | |
VERSION="${{ inputs.version }}" | |
fi | |
# Set the appropriate env var | |
suffix="_VERSION" | |
if [[ "${{ inputs.type }}" == "preview" ]]; then | |
suffix="_PREVIEW_VERSION" | |
elif [[ "${{ inputs.type }}" == "daily" ]]; then | |
suffix="_DAILY_VERSION" | |
fi | |
product="${{ inputs.product }}" | |
if [[ "$product" == "connect" ]] || [[ "$product" == "connect-content-init" ]] || [[ "$product" == "content-images" ]]; then | |
product="CONNECT" | |
elif [[ "$product" == "package-manager" ]]; then | |
product="PACKAGE_MANAGER" | |
else | |
product="WORKBENCH" | |
fi | |
echo "Setting $product$suffix=$VERSION" | |
echo "$product$suffix=$VERSION" >> $GITHUB_ENV | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
id: setup-buildx | |
with: | |
buildkitd-config: ./share/buildkitd.toml | |
- name: Build/Test/Push manual build image | |
uses: ./.github/actions/bake-test-push | |
with: | |
target: ${{ steps.get-target.outputs.TARGET }} | |
bakefile: ${{ needs.setup.outputs.BAKE_FILE }} | |
push-image: ${{ inputs.push }} | |
ghcr-token: ${{ secrets.GITHUB_TOKEN }} | |
dockerhub-username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
dockerhub-token: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
gcp-json: '${{ secrets.GCP_ARTIFACT_REGISTRY_JSON }}' | |
snyk-org: ${{ secrets.SNYK_ORG }} | |
snyk-token: '${{ secrets.SNYK_TOKEN }}' |