Docker Deploy #802
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
# Copyright © 2022 Cask Data, Inc. | |
# Licensed under the Apache License, Version 2.0 (the "License"); you may not | |
# use this file except in compliance with the License. You may obtain a copy of | |
# the License at | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |
# License for the specific language governing permissions and limitations under | |
# the License. | |
# This workflow depends on https://github.com/cdapio/cdap-build/releases to download the cdap-sandbox for the particular CDAP Version. | |
name: Docker Deploy | |
on: | |
schedule: | |
- cron: '0 15 * * *' | |
workflow_dispatch: | |
# workaround to run manual trigger for a particular branch | |
inputs: | |
branch: | |
description: "branch name on which workflow will be triggered" | |
required: true | |
default: "develop" | |
update_submodules_remote: | |
description: "update submodules with latest commits from the remote branch" | |
required: true | |
type: boolean | |
default: true | |
env: | |
TAG_NAME: latest | |
jobs: | |
set-branch-matrix: | |
runs-on: ubuntu-latest | |
steps: | |
- name: set-matrix | |
run: | | |
if [ ${{ github.event_name }} != "workflow_dispatch" ]; | |
then | |
echo 'BRANCH_MATRIX={"include":[{"branch":"develop"}]}' >> $GITHUB_ENV | |
else | |
echo 'BRANCH_MATRIX={"include":[{"branch":"${{ github.event.inputs.branch }}"}]}' >> $GITHUB_ENV | |
fi | |
outputs: | |
matrix: ${{ env.BRANCH_MATRIX }} | |
docker-deploy: | |
needs: set-branch-matrix | |
runs-on: cdapio-hub-k8-runner | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJson(needs.set-branch-matrix.outputs.matrix) }} | |
steps: | |
- name: Recursively Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
submodules: recursive | |
path: cdap-build | |
ref: ${{ matrix.branch }} | |
- name: Update Submodules | |
working-directory: cdap-build | |
if: ${{ github.event.inputs.update_submodules_remote != 'false' }} | |
run: | | |
git submodule update --init --recursive --remote | |
- name: Cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ github.workflow }}-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven-${{ github.workflow }} | |
- name: Set up CDAP Version | |
working-directory: cdap-build/cdap | |
run: | | |
export VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout) | |
echo "CDAP_VERSION=${VERSION}" | |
echo "CDAP_VERSION=${VERSION}" >> $GITHUB_ENV | |
- name: Set up TAG name | |
working-directory: cdap-build | |
run: | | |
if [ ${{ matrix.branch }} != "develop" ]; | |
then | |
echo "TAG_NAME=v${{ env.CDAP_VERSION }}" >> $GITHUB_ENV | |
sed -i -e "s#{{TAG}}#${{ env.CDAP_VERSION }}#g" .github/workflows/cloudbuild.json | |
else | |
sed -i -e "s#{{TAG}}#${{ env.TAG_NAME }}#g" .github/workflows/cloudbuild.json | |
fi | |
cat .github/workflows/cloudbuild.json | |
- name: Set up CDAP SDK with URI | |
working-directory: cdap-build/cdap/cdap-distributions/src | |
run: | | |
sed \ | |
-e "s#{{VERSION}}#${{env.CDAP_VERSION}}-1#g" \ | |
-e "s#{{URI}}#https://github.com/cdapio/cdap-build/releases/download/${{ env.TAG_NAME }}/cdap-sandbox-${{ env.CDAP_VERSION }}.zip#g" \ | |
packer/files/cdap-sdk-with-uri.json.template > packer/files/cdap-sdk.json | |
cat packer/files/cdap-sdk.json | |
chmod +x packer/scripts/*.sh | |
mkdir -p ../target | |
- name: Trigger Cloud Build | |
working-directory: cdap-build | |
run: | | |
gcloud builds submit --config .github/workflows/cloudbuild.json . --timeout=1800s |