2021-11-24 18:45:21 +00:00
|
|
|
name: Push latest Docker image
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
# Trigger if latest_candidate updates. This is automatically done by another
|
|
|
|
# workflow whenever tests pass on main - but events don't chain without using
|
|
|
|
# personal access tokens so we just use a cron job.
|
|
|
|
branches: [ latest_candidate ]
|
|
|
|
schedule:
|
|
|
|
# Run at 5:41 UTC daily
|
|
|
|
- cron: '41 5 * * *'
|
|
|
|
workflow_dispatch:
|
2024-06-21 21:55:30 +00:00
|
|
|
inputs:
|
2024-07-08 17:23:36 +00:00
|
|
|
branch:
|
2024-06-26 19:24:47 +00:00
|
|
|
description: "Branch from which to create the latest Docker image (default: latest_candidate)"
|
2024-06-21 21:55:30 +00:00
|
|
|
type: string
|
|
|
|
required: true
|
2024-07-08 17:23:36 +00:00
|
|
|
default: latest_candidate
|
|
|
|
disable_tests:
|
|
|
|
description: "Should the tests be skipped?"
|
|
|
|
type: boolean
|
|
|
|
required: True
|
|
|
|
default: False
|
|
|
|
platforms:
|
|
|
|
description: "Platforms to build"
|
|
|
|
type: choice
|
|
|
|
required: True
|
|
|
|
options:
|
|
|
|
- linux/amd64
|
|
|
|
- linux/arm64/v8
|
|
|
|
- linux/amd64,linux/arm64/v8
|
|
|
|
default: linux/amd64,linux/arm64/v8
|
|
|
|
tag:
|
|
|
|
description: "Tag for the resulting images"
|
|
|
|
type: string
|
|
|
|
required: True
|
2024-07-11 16:55:55 +00:00
|
|
|
default: 'latest'
|
2024-07-08 17:23:36 +00:00
|
|
|
|
|
|
|
env:
|
|
|
|
BRANCH: ${{ inputs.branch || 'latest_candidate' }}
|
|
|
|
PLATFORMS: ${{ inputs.platforms || 'linux/amd64,linux/arm64/v8' }}
|
2024-07-11 16:55:55 +00:00
|
|
|
TAG: ${{ inputs.tag || 'latest' }}
|
2024-07-08 17:23:36 +00:00
|
|
|
DOCKER_HUB_OWNER: ${{ vars.DOCKER_HUB_OWNER || github.repository_owner }}
|
2021-11-24 18:45:21 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
push_to_registry:
|
|
|
|
name: Push latest Docker image to Docker Hub
|
|
|
|
runs-on: ubuntu-latest
|
2021-12-13 18:35:00 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2022-09-06 15:46:52 +00:00
|
|
|
python-version: [3.9]
|
2023-10-11 21:03:02 +00:00
|
|
|
node-version: [18.x]
|
2024-06-21 21:55:30 +00:00
|
|
|
image:
|
2024-06-21 21:56:07 +00:00
|
|
|
# We build two images, `grist-oss` and `grist`.
|
|
|
|
# See https://github.com/gristlabs/grist-core?tab=readme-ov-file#available-docker-images
|
2024-06-21 21:55:30 +00:00
|
|
|
- name: "grist-oss"
|
|
|
|
repo: "grist-core"
|
|
|
|
- name: "grist"
|
|
|
|
repo: "grist-ee"
|
2021-11-24 18:45:21 +00:00
|
|
|
steps:
|
2024-07-08 17:23:36 +00:00
|
|
|
- name: Build settings
|
|
|
|
run: |
|
|
|
|
echo "Branch: $BRANCH"
|
|
|
|
echo "Platforms: $PLATFORMS"
|
|
|
|
echo "Docker Hub Owner: $DOCKER_HUB_OWNER"
|
|
|
|
echo "Tag: $TAG"
|
|
|
|
|
2021-11-24 18:45:21 +00:00
|
|
|
- name: Check out the repo
|
2024-07-08 17:23:36 +00:00
|
|
|
uses: actions/checkout@v4
|
2021-11-24 18:45:21 +00:00
|
|
|
with:
|
2024-07-08 17:23:36 +00:00
|
|
|
ref: ${{ env.BRANCH }}
|
2024-06-21 21:55:30 +00:00
|
|
|
|
2024-07-11 20:00:30 +00:00
|
|
|
- name: Add a dummy ext/ directory
|
|
|
|
run:
|
|
|
|
mkdir ext && touch ext/dummy
|
|
|
|
|
2024-06-21 21:55:30 +00:00
|
|
|
- name: Check out the ext/ directory
|
|
|
|
if: matrix.image.name != 'grist-oss'
|
|
|
|
run: buildtools/checkout-ext-directory.sh ${{ matrix.image.repo }}
|
|
|
|
|
2022-04-03 23:43:29 +00:00
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v1
|
2024-06-21 21:55:30 +00:00
|
|
|
|
2022-04-03 23:43:29 +00:00
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
2024-06-21 21:55:30 +00:00
|
|
|
|
2021-12-13 18:35:00 +00:00
|
|
|
- name: Prepare image but do not push it yet
|
2022-04-03 23:43:29 +00:00
|
|
|
uses: docker/build-push-action@v2
|
2021-12-13 18:35:00 +00:00
|
|
|
with:
|
2022-04-03 23:43:29 +00:00
|
|
|
context: .
|
|
|
|
load: true
|
2024-07-08 17:23:36 +00:00
|
|
|
tags: ${{ env.DOCKER_HUB_OWNER }}/${{ matrix.image.name }}:${{ env.TAG }}
|
2022-04-07 01:41:03 +00:00
|
|
|
cache-from: type=gha
|
2024-07-08 18:03:18 +00:00
|
|
|
build-contexts: ext=ext
|
2024-06-21 21:55:30 +00:00
|
|
|
|
2021-12-13 18:35:00 +00:00
|
|
|
- name: Use Node.js ${{ matrix.node-version }} for testing
|
2024-07-08 17:23:36 +00:00
|
|
|
if: ${{ !inputs.disable_tests }}
|
2021-12-13 18:35:00 +00:00
|
|
|
uses: actions/setup-node@v1
|
|
|
|
with:
|
|
|
|
node-version: ${{ matrix.node-version }}
|
2024-06-21 21:55:30 +00:00
|
|
|
|
2021-12-13 18:35:00 +00:00
|
|
|
- name: Set up Python ${{ matrix.python-version }} for testing - maybe not needed
|
2024-07-08 17:23:36 +00:00
|
|
|
if: ${{ !inputs.disable_tests }}
|
2021-12-13 18:35:00 +00:00
|
|
|
uses: actions/setup-python@v2
|
|
|
|
with:
|
|
|
|
python-version: ${{ matrix.python-version }}
|
2024-06-21 21:55:30 +00:00
|
|
|
|
2021-12-13 18:35:00 +00:00
|
|
|
- name: Install Python packages
|
2024-07-08 17:23:36 +00:00
|
|
|
if: ${{ !inputs.disable_tests }}
|
2021-12-13 18:35:00 +00:00
|
|
|
run: |
|
|
|
|
pip install virtualenv
|
|
|
|
yarn run install:python
|
2024-06-21 21:55:30 +00:00
|
|
|
|
2021-12-13 18:35:00 +00:00
|
|
|
- name: Install Node.js packages
|
2024-07-08 17:23:36 +00:00
|
|
|
if: ${{ !inputs.disable_tests }}
|
2021-12-13 18:35:00 +00:00
|
|
|
run: yarn install
|
2024-06-21 21:55:30 +00:00
|
|
|
|
2024-07-10 17:08:19 +00:00
|
|
|
- name: Disable the ext/ directory
|
|
|
|
if: ${{ !inputs.disable_tests }}
|
|
|
|
run: mv ext/ ext-disabled/
|
|
|
|
|
2021-12-13 18:35:00 +00:00
|
|
|
- name: Build Node.js code
|
2024-07-08 17:23:36 +00:00
|
|
|
if: ${{ !inputs.disable_tests }}
|
2024-07-10 17:08:19 +00:00
|
|
|
run: yarn run build:prod
|
2024-06-21 21:55:30 +00:00
|
|
|
|
2021-12-13 18:35:00 +00:00
|
|
|
- name: Run tests
|
2024-07-08 17:23:36 +00:00
|
|
|
if: ${{ !inputs.disable_tests }}
|
|
|
|
run: TEST_IMAGE=${{ env.DOCKER_HUB_OWNER }}/${{ matrix.image.name }}:${{ env.TAG }} VERBOSE=1 DEBUG=1 MOCHA_WEBDRIVER_HEADLESS=1 yarn run test:docker
|
2024-06-21 21:55:30 +00:00
|
|
|
|
2024-07-10 17:08:19 +00:00
|
|
|
- name: Re-enable the ext/ directory
|
|
|
|
if: ${{ !inputs.disable_tests }}
|
|
|
|
run: mv ext-disabled/ ext/
|
2024-06-29 00:15:59 +00:00
|
|
|
|
2022-04-03 23:43:29 +00:00
|
|
|
- name: Log in to Docker Hub
|
|
|
|
uses: docker/login-action@v1
|
2021-11-24 18:45:21 +00:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
2024-06-21 21:55:30 +00:00
|
|
|
|
2022-04-03 23:43:29 +00:00
|
|
|
- name: Push to Docker Hub
|
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
context: .
|
2024-07-08 17:23:36 +00:00
|
|
|
platforms: ${{ env.PLATFORMS }}
|
2022-04-03 23:43:29 +00:00
|
|
|
push: true
|
2024-07-08 17:23:36 +00:00
|
|
|
tags: ${{ env.DOCKER_HUB_OWNER }}/${{ matrix.image.name }}:${{ env.TAG }}
|
2022-04-07 01:41:03 +00:00
|
|
|
cache-from: type=gha
|
|
|
|
cache-to: type=gha,mode=max
|
2024-07-08 18:03:18 +00:00
|
|
|
build-contexts: ext=ext
|
2024-06-21 21:55:30 +00:00
|
|
|
|
2024-07-08 17:23:36 +00:00
|
|
|
- name: Push Enterprise to Docker Hub
|
|
|
|
if: ${{ matrix.image.name == 'grist' }}
|
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
build-args: |
|
|
|
|
BASE_IMAGE=${{ env.DOCKER_HUB_OWNER }}/${{ matrix.image.name}}
|
|
|
|
BASE_VERSION=${{ env.TAG }}
|
|
|
|
file: ext/Dockerfile
|
|
|
|
platforms: ${{ env.PLATFORMS }}
|
|
|
|
push: true
|
|
|
|
tags: ${{ env.DOCKER_HUB_OWNER }}/grist-ee:${{ env.TAG }}
|
|
|
|
cache-from: type=gha
|
|
|
|
cache-to: type=gha,mode=max
|
|
|
|
|
2024-06-26 21:02:45 +00:00
|
|
|
update_latest_branch:
|
|
|
|
name: Update latest branch
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: push_to_registry
|
|
|
|
steps:
|
|
|
|
- name: Check out the repo
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
ref: ${{ inputs.latest_branch }}
|
|
|
|
|
2021-11-24 18:45:21 +00:00
|
|
|
- name: Update latest branch
|
|
|
|
uses: ad-m/github-push-action@8407731efefc0d8f72af254c74276b7a90be36e1
|
|
|
|
with:
|
|
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
branch: latest
|
|
|
|
force: true
|