Skip to content

Commit

Permalink
Rebase and merge WGCW workflow into release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ianpittwood committed Aug 8, 2023
1 parent 7d1b98d commit 0400594
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 91 deletions.
16 changes: 16 additions & 0 deletions .github/actions/build-test-scan-push/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ inputs:
description: Username for authentication with DockerHub
required: true
type: string
gcp-json:
description: JSON for authenticating Google Cloud Platform
default: ""
type: string

runs:
using: "composite"
Expand All @@ -71,6 +75,18 @@ runs:
username: ${{ inputs.dockerhub-username }}
password: ${{ inputs.dockerhub-token }}

- name: Authenticate to Google Cloud
continue-on-error: true
uses: google-github-actions/auth@v1
with:
credentials_json: '${{ inputs.gcp-json }}'

- name: Authenticate GCAR
run: |
if [[ "${{ inputs.gcp-json }}" != "" ]]; then
gcloud auth configure-docker -q us-central1-docker.pkg.dev
fi
- name: Build
id: image-build
uses: docker/build-push-action@v4
Expand Down
83 changes: 83 additions & 0 deletions .github/workflows/build-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,86 @@ jobs:
dockerhub-token: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

# End retry logic

build-workbench-for-google-cloud-workstations:
needs: [ build-base, build-base-pro ]
runs-on: ubuntu-latest
name: build-workbench-for-google-cloud-workstations

concurrency:
group: build-products-${{ matrix.config.product }}-${{ matrix.config.os }}-${{ github.ref }}
cancel-in-progress: true

steps:
- name: Check Out Repo
uses: actions/checkout@v3

- name: Set up Just
uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Get Version
id: get-version
run: |
VERSION=$(just workbench-for-google-cloud-workstations/get-version)
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Get build args
id: get-build-args
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
BUILD_ARGS=$(just workbench-for-google-cloud-workstations/get-build-args)
echo "BUILD_ARGS<<$EOF" >> $GITHUB_OUTPUT
echo "$BUILD_ARGS" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
- name: Get tags
id: get-tags
run: |
IMAGE_TAGS=$(just workbench-for-google-cloud-workstations/get-build-tags)
echo "IMAGE_TAGS=$IMAGE_TAGS" >> $GITHUB_OUTPUT
- name: Build/Test/Scan/Push base pro image
id: build1
uses: ./.github/actions/build-test-scan-push
continue-on-error: true
with:
context: ./workbench-for-google-cloud-workstations
os: ubuntu2004
product: workbench-for-google-cloud-workstations
image-tags: ${{ steps.get-tags.outputs.IMAGE_TAGS }}
build-args: ${{ steps.get-build-args.outputs.BUILD_ARGS }}
push-image: ${{ github.ref == 'refs/heads/main' }}
snyk-token: ${{ secrets.SNYK_TOKEN }}
snyk-org-id: ${{ secrets.SNYK_ORG_ID }}
ghcr-token: ${{ secrets.BUILD_PAT }}
dockerhub-username: ${{ secrets.DOCKER_HUB_USERNAME }}
dockerhub-token: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
gcp-json: '${{ secrets.GCP_ARTIFACT_REGISTRY_JSON }}'

# Begin retry logic

- name: Wait 60s on failure before retrying
if: steps.build1.outcome == 'failure'
run: sleep 60

- name: Retry - Build/Test/Scan/Push base pro image
id: build2
if: steps.build1.outcome == 'failure'
uses: ./.github/actions/build-test-scan-push
with:
context: ./workbench-for-google-cloud-workstations
os: ubuntu2004
product: workbench-for-google-cloud-workstations
image-tags: ${{ steps.get-tags.outputs.IMAGE_TAGS }}
build-args: ${{ steps.get-build-args.outputs.BUILD_ARGS }}
push-image: ${{ github.ref == 'refs/heads/main' }}
snyk-token: ${{ secrets.SNYK_TOKEN }}
snyk-org-id: ${{ secrets.SNYK_ORG_ID }}
ghcr-token: ${{ secrets.BUILD_PAT }}
dockerhub-username: ${{ secrets.DOCKER_HUB_USERNAME }}
dockerhub-token: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
gcp-json: '${{ secrets.GCP_ARTIFACT_REGISTRY_JSON }}'

# End retry logic
85 changes: 0 additions & 85 deletions .github/workflows/build-workbench-for-gcw.yaml

This file was deleted.

8 changes: 4 additions & 4 deletions workbench-for-google-cloud-workstations/.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ RSW_VERSION=2023.03.2+454.pro2
RSW_TAG_VERSION=2023.03.2-454.pro2
RSW_DOWNLOAD_URL=https://download2.rstudio.org/server/bionic/amd64
RSW_NAME=rstudio-workbench
PYTHON_VERSION=3.10.11
PYTHON_VERSION_ALT=3.9.16
PYTHON_VERSION_JUPYTER=3.10.11
PYTHON_VERSION=3.10.12
PYTHON_VERSION_ALT=3.9.17
PYTHON_VERSION_JUPYTER=3.10.12
R_VERSION=4.2.3
R_VERSION_ALT=4.1.3
DRIVERS_VERSION=2023.05.0
QUARTO_VERSION=1.3.324
QUARTO_VERSION=1.3.340
IMAGE_REGISTRY_NAME=us-central1-docker.pkg.dev/posit-images/cloud-workstations/workbench
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM us-central1-docker.pkg.dev/cloud-workstations-images/predefined/base:latest
FROM us-central1-docker.pkg.dev/cloud-workstations-images/predefined/base:public-image-current

### ARG declarations ###
ARG DEBIAN_FRONTEND=noninteractive
Expand Down
23 changes: 22 additions & 1 deletion workbench-for-google-cloud-workstations/Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,27 @@ RSW_LICENSE_SERVER := ""
_make-default-tag:
echo "${IMAGE_REGISTRY_NAME}:$(just -f ../Justfile _get-tag-safe-version "${RSW_VERSION}")"

get-version:
echo "${RSW_VERSION}"

get-build-args:
#!/usr/bin/env bash
printf "RSW_VERSION=${RSW_VERSION}
R_VERSION=${R_VERSION}
R_VERSION_ALT=${R_VERSION_ALT}
PYTHON_VERSION=${PYTHON_VERSION}
PYTHON_VERSION_ALT=${PYTHON_VERSION_ALT}
PYTHON_VERSION_JUPYTER=${PYTHON_VERSION_JUPYTER}
QUARTO_VERSION=${QUARTO_VERSION}
DRIVERS_VERSION=${DRIVERS_VERSION}
SRC_IMAGE_NAME=${SRC_IMAGE_NAME}
RSW_DOWNLOAD_URL=${RSW_DOWNLOAD_URL}"
get-build-tags:
#!/usr/bin/env bash
echo ${IMAGE_REGISTRY_NAME}:${RSW_TAG_VERSION},\
${IMAGE_REGISTRY_NAME}:latest
# Build Workbench image - just build 2022.07.2+576.pro12 rstudio/rstudio-workbench-gcw:2022.07.2
build *TAGS="":
#!/usr/bin/env bash
Expand Down Expand Up @@ -45,7 +66,7 @@ build *TAGS="":
--build-arg QUARTO_VERSION="${QUARTO_VERSION}" \
--build-arg DRIVERS_VERSION="${DRIVERS_VERSION}" \
--build-arg RSW_DOWNLOAD_URL="${RSW_DOWNLOAD_URL}" \
--file=./Dockerfile .
--file=./Dockerfile.ubuntu2004 .

echo ${raw_tag_array[@]}

Expand Down

0 comments on commit 0400594

Please sign in to comment.