Test, build and push Docker Image #46
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: Test, build and push Docker Image | |
on: | |
# This line enables manual triggering of this workflow. | |
workflow_dispatch: | |
# trigger for pushes to release and master | |
push: | |
branches: [release, master] | |
paths: | |
- "app/client/**" | |
- "app/server/**" | |
- "app/client/packages/rts/**" | |
- "!app/client/cypress/manual_TestSuite/**" | |
jobs: | |
server-build: | |
name: server-build | |
uses: ./.github/workflows/server-build.yml | |
secrets: inherit | |
with: | |
pr: 0 | |
client-build: | |
name: client-build | |
uses: ./.github/workflows/client-build.yml | |
secrets: inherit | |
with: | |
pr: 0 | |
rts-build: | |
name: rts-build | |
uses: ./.github/workflows/rts-build.yml | |
secrets: inherit | |
with: | |
pr: 0 | |
build-docker-image: | |
needs: [ client-build, server-build, rts-build ] | |
# Only run if the build step is successful | |
if: success() | |
name: build-docker-image | |
uses: ./.github/workflows/build-docker-image.yml | |
secrets: inherit | |
with: | |
pr: 0 | |
package: | |
needs: build-docker-image | |
runs-on: ubuntu-latest | |
# Set permissions since we're using OIDC token authentication between Depot and GitHub | |
permissions: | |
contents: read | |
id-token: write | |
# Run this job irrespective of tests failing, if this is the release branch; or only if the tests pass, if this is the master branch. | |
if: (success() && github.ref == 'refs/heads/master') || | |
( always() && | |
( | |
github.event_name == 'workflow_dispatch' || | |
github.event_name == 'push' || | |
( | |
github.event_name == 'pull_request_review' && | |
github.event.review.state == 'approved' && | |
github.event.pull_request.head.repo.full_name == github.repository | |
) | |
) && | |
(github.ref == 'refs/heads/release' || startsWith(github.ref, 'refs/heads/convo/')) | |
) | |
steps: | |
# Checkout the code | |
- name: Checkout the merged commit from PR and base branch | |
if: github.event_name == 'pull_request_review' | |
uses: actions/checkout@v3 | |
with: | |
ref: refs/pull/${{ github.event.pull_request.number }}/merge | |
- name: Checkout the head commit of the branch | |
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
uses: actions/checkout@v3 | |
- name: Download the react build artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: client-build | |
path: app/client | |
- name: Unpack the client build artifact | |
if: steps.run_result.outputs.run_result != 'success' | |
run: | | |
mkdir -p app/client/build | |
tar -xvf app/client/build.tar -C app/client/build | |
- name: Download the server build artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: server-build | |
path: app/server/dist | |
- name: Download the rts build artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: rts-dist | |
path: app/client/packages/rts | |
- name: Untar the rts folder | |
run: | | |
tar -xvf app/client/packages/rts/rts-dist.tar -C app/client/packages/rts/ | |
echo "Cleaning up the tar files" | |
rm app/client/packages/rts/rts-dist.tar | |
cp -r app/client/packages/rts/dist app/rts/dist | |
# Here, the GITHUB_REF is of type /refs/head/<branch_name>. We extract branch_name from this by removing the | |
# first 11 characters. This can be used to build images for several branches | |
- name: Get the version to tag the Docker image | |
id: vars | |
run: echo tag=$(echo ${GITHUB_REF:17}) >> $GITHUB_OUTPUT | |
- name: Set up Docker buildx CLI | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
# Build master Docker image and push to Docker Hub | |
- name: Push client master image to Docker Hub with commit tag | |
if: success() | |
uses: docker/build-push-action@v4 | |
with: | |
context: app/client | |
push: true | |
platforms: linux/arm64,linux/amd64 | |
tags: ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-editor:${{steps.vars.outputs.tag}} | |
# Build master Docker image and push to Docker Hub | |
- name: Push server master image to Docker Hub with commit tag | |
if: success() | |
uses: docker/build-push-action@v4 | |
with: | |
context: app/server | |
platforms: linux/arm64,linux/amd64 | |
push: true | |
tags: ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-server:${{steps.vars.outputs.tag}} | |
# Build master Docker image and push to Docker Hub | |
- name: Push RTS master image to Docker Hub with commit tag | |
if: success() && startsWith(github.ref, 'refs/heads/convo/') | |
uses: docker/build-push-action@v4 | |
with: | |
context: app/rts | |
platforms: linux/arm64,linux/amd64 | |
push: true | |
tags: ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-rts:${{steps.vars.outputs.tag}} |