Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 327110f

Browse files
authored
Merge pull request #1175 from utPLSQL/feature/github_actions
Add build process using Github Actions
2 parents a45cc3c + b94a3f7 commit 327110f

32 files changed

Lines changed: 475 additions & 625 deletions

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
.travis.yml export-ignore
55
mkdocs.yml export-ignore
66
.travis export-ignore
7+
.github export-ignore
78
sonar-project.properties export-ignore
89
tests export-ignore
910
development export-ignore
File renamed without changes.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/usr/bin/env bash
22

33
#When building a new version from a release branch, the version is taken from release branch name
4-
if [[ "${CURRENT_BRANCH}" =~ ^release/v[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
5-
version=${CURRENT_BRANCH#release\/}
4+
if [[ "${CI_ACTION_REF_NAME}" =~ ^release/v[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
5+
version=${CI_ACTION_REF_NAME#release\/}
66
else
77
#Otherwise, version is taken from the VERSION file
88
version=`cat VERSION`
99
#When on develop branch, add "-develop" to the version text
10-
if [[ "${CURRENT_BRANCH}" == "develop" ]]; then
10+
if [[ "${CI_ACTION_REF_NAME}" == "develop" ]]; then
1111
version=`sed -E "s/(v?[0-9]+\.[0-9]+\.[0-9]+).*/\1-develop/" <<< "${version}"`
1212
fi
1313
fi
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -ev
44
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
5-
cd ${SCRIPT_DIR}/../source
5+
cd ${SCRIPT_DIR}/../../source
66

77
INSTALL_FILE="install_headless_with_trigger.sql"
88
if [[ ! -f "${INSTALL_FILE}" ]]; then
@@ -20,8 +20,7 @@ alter session set plsql_optimize_level=0;
2020
@${INSTALL_FILE} $UT3_DEVELOP_SCHEMA $UT3_DEVELOP_SCHEMA_PASSWORD
2121
SQL
2222

23-
#Run this step only on second child job (12.1 - at it's fastest)
24-
if [[ "${JOB_NUMBER}" =~ \.2$ ]]; then
23+
if [[ "${MATRIX_JOB_ID}" == 1 ]]; then
2524

2625
#check code-style for errors
2726
time "$SQLCLI" $UT3_DEVELOP_SCHEMA/$UT3_DEVELOP_SCHEMA_PASSWORD@//$CONNECTION_STR @../development/utplsql_style_check.sql

.travis/install_utplsql_release.sh renamed to .github/scripts/install_utplsql_release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -ev
44
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
5-
cd ${SCRIPT_DIR}/../${UTPLSQL_DIR}/source
5+
cd ${SCRIPT_DIR}/../../${UTPLSQL_DIR}/source
66

77
"$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<SQL
88
set serveroutput on
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/bin/bash
2+
3+
# Based on `push_docs_to_gh_pages.sh`
4+
# Significant alterations
5+
# - Support for multiple copies of documentation,
6+
# - only clearing out develop
7+
# - index.md logging doc history
8+
9+
# How to run:
10+
# - From repository root .github/scripts/push_docs_to_gh_pages.sh
11+
12+
# Required files / directories (relative from repo root)
13+
# - File: "docs/index.md" with that contains develop docs
14+
15+
# Required ENV Variables
16+
LATEST_DOCS_BRANCH="develop"
17+
GITHUB_IO_REPO='utPLSQL/utPLSQL.github.io'
18+
GITHUB_IO_BRANCH='main'
19+
DOCS_DIR='../../docs/.'
20+
21+
# ENV Variable checks are to help with configuration troubleshooting, they silently exit with unique message.
22+
# Anyone one of them not set can be used to turn off this functionality.
23+
24+
# If a version of the project is not defined
25+
[[ -n "${UTPLSQL_VERSION}" ]] || { echo "variable UTPLSQL_VERSION is not defines or missing value"; exit 1; }
26+
# Fail if the markdown documentation is not present.
27+
[[ -f ./docs/index.md ]] || { echo "file docs/index.md not found"; exit 1; }
28+
29+
# Store latest commit SHA to be used when committing and pushing to github.io repo
30+
SHA=`git rev-parse --verify HEAD`
31+
32+
# clone the repository and switch to GITHUB_IO_BRANCH branch
33+
mkdir pages
34+
cd ./pages
35+
git clone --depth 1 https://${API_TOKEN_GITHUB}@github.com/${GITHUB_IO_REPO} -b ${GITHUB_IO_BRANCH} .
36+
37+
mkdir -p utPLSQL
38+
cd ./utPLSQL
39+
#clear out develop documentation directory and copy docs contents to it.
40+
echo "updating 'develop' documentation directory"
41+
mkdir -p ./develop
42+
rm -rf ./develop/**./* || exit 0
43+
cp -a ${DOCS_DIR} ./develop
44+
45+
# If a Tagged Build then copy to it's own directory as well and to the 'latest' release directory
46+
if [ "${GITHUB_REF_TYPE}" == "tag" ]; then
47+
echo "Creating directory ./${UTPLSQL_VERSION}"
48+
mkdir -p ./${UTPLSQL_VERSION}
49+
rm -rf ./${UTPLSQL_VERSION}/**./* || exit 0
50+
cp -a ${DOCS_DIR} ./${UTPLSQL_VERSION}
51+
echo "Populating 'latest' directory"
52+
mkdir -p ./latest
53+
rm -rf ./latest/**./* || exit 0
54+
cp -a ${DOCS_DIR} ./latest
55+
fi
56+
# Stage changes for commit
57+
git add .
58+
59+
#Check if there are doc changes, if none exit the script
60+
if [[ -z `git diff HEAD --exit-code` ]]; then
61+
echo "No changes to docs detected."
62+
exit 0
63+
fi
64+
#Changes where detected, so we need to update the version log.
65+
now=$(date +"%d %b %Y - %r")
66+
if [ ! -f index.md ]; then
67+
echo "---" >>index.md
68+
echo "layout: default" >>index.md
69+
echo "---" >>index.md
70+
echo "<!-- Auto generated from .github/scripts/push_docs_to_github_io.sh -->" >>index.md
71+
echo "# Documentation versions" >>index.md
72+
echo "" >>index.md
73+
echo "" >>index.md #- 7th line - placeholder for latest release doc
74+
echo "" >>index.md #- 8th line - placeholder for develop branch doc
75+
echo "" >>index.md
76+
echo "## Released Version Doc History" >>index.md
77+
echo "" >>index.md
78+
fi
79+
#If build running on a TAG - it's a new release - need to add it to documentation
80+
if [ "${GITHUB_REF_TYPE}" == "tag" ]; then
81+
sed -i '7s@.*@'" - [Latest ${CI_ACTION_REF_NAME} documentation](latest/) - Created $now"'@' index.md
82+
#add entry to the top of version history (line end of file - ## Released Version Doc History
83+
sed -i '12i'" - [${CI_ACTION_REF_NAME} documentation](${UTPLSQL_VERSION}/) - Created $now" index.md
84+
fi
85+
#replace 4th line in log
86+
sed -i '8s@.*@'" - [Latest development version](develop/) - Created $now"'@' index.md
87+
#Add and Commit the changes back to pages repo.
88+
git add .
89+
git commit -m "Deploy to gh-pages branch: base commit ${SHA}"
90+
# Now that we're all set up, we can push.
91+
git push --quiet origin HEAD:${GITHUB_IO_BRANCH}
92+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
set -v
4+
echo Current branch is "${CURRENT_BRANCH}"
5+
echo "Committing version & buildNo into branch (${CURRENT_BRANCH})"
6+
git add sonar-project.properties
7+
git add VERSION
8+
git add source/*
9+
git add docs/*
10+
git commit -m 'Updated project version after build [skip ci]'
11+
echo "Pushing to origin"
12+
git push --quiet origin HEAD:${CURRENT_BRANCH}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -ev
44
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
5-
cd ${SCRIPT_DIR}/../examples
5+
cd ${SCRIPT_DIR}/../../examples
66

77
"$SQLCLI" $UT3_DEVELOP_SCHEMA/$UT3_DEVELOP_SCHEMA_PASSWORD@//$CONNECTION_STR <<SQL
88
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
UTPLSQL_BUILD_NO=$( expr ${GITHUB_RUN_NUMBER} + ${UTPLSQL_BUILD_NO_OFFSET} )
4+
UTPLSQL_VERSION=$(.github/scripts/get_project_version.sh)
5+
6+
echo "UTPLSQL_BUILD_NO=${UTPLSQL_BUILD_NO}" >> $GITHUB_ENV
7+
echo "UTPLSQL_VERSION=${UTPLSQL_VERSION}" >> $GITHUB_ENV
8+
echo UTPLSQL_BUILD_VERSION=$(echo ${UTPLSQL_VERSION} | sed -E "s/(v?[0-9]+\.)([0-9]+\.)([0-9]+)(-.*)?/\1\2\3\.${UTPLSQL_BUILD_NO}\4/") >> $GITHUB_ENV
9+
10+
echo "CURRENT_BRANCH=${CI_ACTION_REF_NAME}" >> $GITHUB_ENV

0 commit comments

Comments
 (0)