Skip to content

Commit

Permalink
add workflow file for github actions (#379)
Browse files Browse the repository at this point in the history
* add workflow file for github actions

* removed travis yml

* sepereated lint job and go tests job

* changes in the secrets variable name

* removed comments

* change in secret name

* changes

* manual trigger added

* only tag builds will deploy to gh-pages

* changes

Co-authored-by: kumaa43 <[email protected]>
  • Loading branch information
smootherbug and kumaa43 authored Jan 31, 2022
1 parent 69d9a02 commit 70b10a7
Show file tree
Hide file tree
Showing 4 changed files with 217 additions and 104 deletions.
163 changes: 163 additions & 0 deletions .github/workflows/github-actions-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
name: GitHub Actions for pega helm chart

env:
HELM_URL: https://get.helm.sh
HELM_TGZ: helm-v3.2.4-linux-amd64.tar.gz
YAMLLINT_VERSION: 1.15.0
GO_VERSION: 1.13.1


on:
push:
tags:
- '*'
branches-ignore:
- gh-pages
pull_request:
branches: [ master ]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
run-lint-job:
runs-on: ubuntu-18.04
steps:
- name: Check out repository code
uses: actions/checkout@v2

- name: Install yamllint
run: |
sudo pip install yamllint=="${{ env.YAMLLINT_VERSION }}"
- name: run yamllint
run: |
yamllint -c .yamllint.yml -s $(find . -type f -name "Chart.yaml")
yamllint -c .yamllint.yml -s $(find . -type f -name "values*.yaml")
run-remark-job:
runs-on: ubuntu-18.04
steps:
- name: Check out repository code
uses: actions/checkout@v2

- name: Install node
uses: actions/setup-node@v2
with:
node-version: lts/*

- name: Install npm dependencies
run: |
npm install -g --save remark-cli to-vfile remark-preset-lint-recommended remark-validate-links remark-lint-no-dead-urls remark-message-control remark-preset-lint-markdown-style-guide remark-lint
- name: run remark
run: |
remark -i .remark_ignore -f -u validate-links .
run-go-tests-job:
runs-on: ubuntu-18.04
steps:
- name: Check out repository code
uses: actions/checkout@v2

- name: Install GO
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- run: export PATH=$PATH:/usr/local/go/bin

- name: Install Helm
run: |
sudo rm /usr/local/bin/helm
wget -q ${{ env.HELM_URL }}/${{ env.HELM_TGZ }}
tar xzf ${{ env.HELM_TGZ }}
mv linux-amd64/helm /usr/local/bin/helm
- run: helm version

- name: Now load the helm dependencies
run: |
make dependencies
- name: Prepare for GO helm unit tests
run: |
mkdir $GITHUB_WORKSPACE/terratest/bin
export GOPATH=$GITHUB_WORKSPACE/terratest
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
export PATH=$PATH:$GITHUB_WORKSPACE/terratest/bin
cd terratest/src/test
dep ensure
- name: run go tests on pega
run: |
export GOPATH=$GITHUB_WORKSPACE/terratest
export PATH=$PATH:$GITHUB_WORKSPACE/terratest/bin
cd terratest/src/test
go test test/pega | grep "FAIL" -A 8 || true ; test ${PIPESTATUS[0]} -eq 0
- name: run go tests on addons
run: |
export GOPATH=$GITHUB_WORKSPACE/terratest
export PATH=$PATH:$GITHUB_WORKSPACE/terratest/bin
cd terratest/src/test
go test test/addons | grep "FAIL" -A 8 || true ; test ${PIPESTATUS[0]} -eq 0
- name: run go tests on backing services
run: |
export GOPATH=$GITHUB_WORKSPACE/terratest
export PATH=$PATH:$GITHUB_WORKSPACE/terratest/bin
cd terratest/src/test
go test test/backingservices | grep "FAIL" -A 8 || true ; test ${PIPESTATUS[0]} -eq 0
run-deploy-job:
runs-on: ubuntu-18.04
needs: [run-lint-job, run-remark-job, run-go-tests-job]
if: ( github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v') ) && success()
steps:
- name: Install Helm
run: |
wget -q ${{ env.HELM_URL }}/${{ env.HELM_TGZ }}
tar xzf ${{ env.HELM_TGZ }}
ls -l
mv linux-amd64/helm /usr/local/bin/helm
- name: Checkout code
uses: actions/checkout@v2

- name: Now load the helm dependencies
run: |
make dependencies
- name: before deploy step 1
run: |
cd $GITHUB_WORKSPACE
chmod 777 before_deploy.sh
./before_deploy.sh
- name: before deploy step 2
run: |
make examples
- name: deploy on github releases
uses: marvinpinto/action-automatic-releases@latest
with:
prerelease: false
files: |
pega-kubernetes-example.tar.gz
pega-openshift-example.tar.gz
pega-azure-aks-example.tar.gz
pega-aws-eks-example.tar.gz
pega-google-gke-example.tar.gz
pega-pivotal-pks-example.tar.gz
repo_token: ${{ secrets.GH_ACTIONS_SECRET }}

- name: deploy on github pages
run: |
cd $GITHUB_WORKSPACE
chmod 777 update_gh_pages.sh
./update_gh_pages.sh
env:
GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_SECRET }}
101 changes: 0 additions & 101 deletions .travis.yml

This file was deleted.

11 changes: 8 additions & 3 deletions before_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

# CHART_VERSION is computed from the TAG details of the commit. Every Github release creates tag with the release name.
# Release name (or) Tag name should be in vX.X.X format. Helm CHART_VERSION would be X.X.X
export CHART_VERSION=$(expr ${TRAVIS_TAG:1})
tagVersion=""
if [ ${GITHUB_REF_TYPE} == "tag" ]
then
tagVersion=${GITHUB_REF_NAME}
fi
export CHART_VERSION=$(expr ${tagVersion:1})
export PEGA_FILE_NAME=pega-${CHART_VERSION}.tgz
export ADDONS_FILE_NAME=addons-${CHART_VERSION}.tgz
export BACKINGSERVICES_FILE_NAME=backingservices-${CHART_VERSION}.tgz
Expand All @@ -12,7 +17,7 @@ export INSTALLER_CONFIGURATIONS_FILE_NAME=installer-config-${CHART_VERSION}.tgz
curl -o index.yaml https://pegasystems.github.io/pega-helm-charts/index.yaml
# Clone the versions from gh-pages to a temp directory - xyz
# The versions will be re-installed in temporary directory - temp_gh_pages
git clone --single-branch --branch gh-pages https://github.com/${TRAVIS_REPO_SLUG} temp_gh_pages
git clone --single-branch --branch gh-pages https://github.com/${GITHUB_REPOSITORY} temp_gh_pages
cp temp_gh_pages/*.tgz .
rm -rf temp_gh_pages
ls
Expand All @@ -23,4 +28,4 @@ helm package --version ${CHART_VERSION} ./charts/backingservices/
tar -czvf ${DEPLOY_CONFIGURATIONS_FILE_NAME} --directory=./charts/pega/config deploy/context.xml.tmpl deploy/server.xml deploy/prconfig.xml deploy/prlog4j2.xml
mkdir -p ./charts/pega/charts/installer/config/installer && cp ./charts/pega/charts/installer/config/migrateSystem.properties.tmpl ./charts/pega/charts/installer/config/installer && cp ./charts/pega/charts/installer/config/prbootstrap.properties.tmpl ./charts/pega/charts/installer/config/installer && cp ./charts/pega/charts/installer/config/prconfig.xml.tmpl ./charts/pega/charts/installer/config/installer && cp ./charts/pega/charts/installer/config/prlog4j2.xml ./charts/pega/charts/installer/config/installer && cp ./charts/pega/charts/installer/config/prpcUtils.properties.tmpl ./charts/pega/charts/installer/config/installer && cp ./charts/pega/charts/installer/config/setupDatabase.properties.tmpl ./charts/pega/charts/installer/config/installer && tar -czvf ${INSTALLER_CONFIGURATIONS_FILE_NAME} --directory=./charts/pega/charts/installer/config installer/migrateSystem.properties.tmpl installer/prbootstrap.properties.tmpl installer/prconfig.xml.tmpl installer/prlog4j2.xml installer/prpcUtils.properties.tmpl installer/setupDatabase.properties.tmpl
# and merge it
helm repo index --merge index.yaml --url https://pegasystems.github.io/pega-helm-charts/ .
helm repo index --merge index.yaml --url https://pegasystems.github.io/pega-helm-charts/ .
46 changes: 46 additions & 0 deletions update_gh_pages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
set -e

echo "${GITHUB_REF}"
echo "${GITHUB_REPOSITORY}"
echo "${GITHUB_ACTOR}"

repo_uri="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
remote_name="origin"
main_branch="master"
target_branch="gh-pages"
tmp_build_dir="/tmp/build_dir"

cd "$GITHUB_WORKSPACE"

git config --global user.name "$GITHUB_ACTOR"
git config --global user.email "${GITHUB_ACTOR}@bots.github.com"

echo "Creating a temporary directory to build"
mkdir -p "$tmp_build_dir"


echo "clone a single branch gh-pages"
git clone --quiet --branch="$target_branch" --depth=1 "$repo_uri" "$tmp_build_dir" > /dev/null

cd "$tmp_build_dir"

echo "Copying the files to the temporary build directory"
rsync -rl --exclude .git --delete "$GITHUB_WORKSPACE/" .

git restore linux-amd64/
echo $(pwd)
ls
git branch

echo "preparing to commit to gh-pages"
git add -A
git commit -qm "Deploy ${GITHUB_REPOSITORY} to ${GITHUB_REPOSITORY}:${target_branch}"
git show --stat-count=10 HEAD

echo "Pushing to gh-pages"
git push -q "$remote_name" "$target_branch" > /dev/null

git status

echo "Pushing to gh-pages complete"

0 comments on commit 70b10a7

Please sign in to comment.