-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from pramod444/develop
[G2P-2999] Added package_docker.yml and push_trigger.yml file for openg2p-landing service.
- Loading branch information
Showing
2 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Build Docker and Push | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
docker-build: | ||
name: Docker Build and Push | ||
runs-on: ubuntu-latest | ||
env: | ||
NAMESPACE: ${{ secrets.docker_hub_organisation }} | ||
SERVICE_NAME: openg2p-landing | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Docker build and push | ||
run: | | ||
BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,') | ||
echo "${{ secrets.docker_hub_token }}" | docker login -u ${{ secrets.docker_hub_actor }} --password-stdin | ||
if [ $? -ne 0 ];then | ||
echo "::error::Failed to Login to dockerhub" | ||
exit 1; | ||
fi | ||
IMAGE_ID=$NAMESPACE/$SERVICE_NAME | ||
# Change all uppercase to lowercase | ||
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | ||
VERSION=$BRANCH_NAME | ||
echo IMAGE_ID=$IMAGE_ID | ||
echo VERSION=$VERSION | ||
docker build . \ | ||
--file Dockerfile \ | ||
--tag $IMAGE_ID:$VERSION | ||
docker push $IMAGE_ID:$VERSION |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
name: Publish OpenG2P-landing Helm charts | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
workflow_dispatch: | ||
inputs: | ||
forcePublishCharts: | ||
description: "Force publish Charts?" | ||
default: "*" | ||
type: string | ||
|
||
|
||
jobs: | ||
generate-charts: | ||
runs-on: ubuntu-latest | ||
env: | ||
SKIP: 'FALSE' | ||
RANCHER_CHART_FILTER: "openg2p.org/add-to-rancher" | ||
defaults: | ||
run: | ||
shell: bash | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
|
||
- id: files | ||
uses: jitterbit/get-changed-files@v1 | ||
|
||
- name: save helm/charts to tmp.txt file | ||
run: | | ||
touch charts-list.txt | ||
for changed_file in ${{ steps.files.outputs.all }}; do | ||
if [[ ${changed_file} =~ ^charts ]]; then | ||
chart_name=$(echo "${changed_file}" | awk -F/ '/^[charts]/{print $2}') | ||
echo $chart_name >> charts-list.txt; | ||
echo "Saved $chart_name chart to charts-list.txt" | ||
fi | ||
done | ||
cat charts-list.txt | sort | uniq > charts-list-unique.txt | ||
mv charts-list-unique.txt charts-list.txt | ||
echo "List of charts to be published"; | ||
cat charts-list.txt | ||
- name: Generate tar files | ||
run: | | ||
if [[ ! -s charts-list.txt ]]; then | ||
echo "::warning::No Charts to publish"; | ||
echo "SKIP=TRUE" >> $GITHUB_ENV | ||
else | ||
RANCHER_CHARTS=() | ||
while IFS= read -r chartpath; do | ||
echo "chartpath: $chartpath" | ||
chartname=$(basename "$chartpath") | ||
echo "Chartname: $chartname" | ||
helm dep up charts/$chartpath | ||
helm package charts/$chartpath | ||
is_rancher_chart=$(grep "$RANCHER_CHART_FILTER" charts/${chartpath%*/}/Chart.yaml || true) | ||
if [ -n "$is_rancher_chart" ]; then | ||
RANCHER_CHARTS+=("$chartname") | ||
fi | ||
done < charts-list.txt | ||
echo "RANCHER_CHARTS=${RANCHER_CHARTS[@]}" >> $GITHUB_ENV | ||
rm charts-list.txt | ||
fi | ||
shopt -s nocasematch | ||
if [[ '${{ github.repository_owner }}' != 'OpenG2P' ]]; then | ||
echo "SKIP=TRUE" >> $GITHUB_ENV | ||
fi | ||
- name: Upload tar as Artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: charts | ||
path: ./*.tgz | ||
if: env.SKIP != 'TRUE' | ||
|
||
- name: Checkout branch for publishing | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: 'openg2p/openg2p-helm' | ||
ref: gh-pages | ||
token: ${{ secrets.OPENG2P_BOT_GITHUB_PAT }} | ||
if: env.SKIP != 'TRUE' | ||
|
||
- name: Download tar from Artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: charts | ||
path: ./ | ||
if: env.SKIP != 'TRUE' | ||
|
||
- name: Update index.yaml | ||
run: | | ||
helm repo index --url https://openg2p.github.io/openg2p-helm/ . | ||
for chartname in $RANCHER_CHARTS; do | ||
cp ${chartname}*.tgz rancher/ | ||
done | ||
helm repo index --url https://openg2p.github.io/openg2p-helm/ --merge rancher/index.yaml rancher | ||
for chartname in $RANCHER_CHARTS; do | ||
rm rancher/${chartname}*.tgz || true | ||
done | ||
if: env.SKIP != 'TRUE' | ||
|
||
- name: Commit Changes to repository | ||
uses: EndBug/add-and-commit@v7 | ||
with: | ||
branch: gh-pages | ||
author_name: openg2pbot | ||
author_email: bot@openg2p.org | ||
default_author: user_info | ||
message: 'added openg2p-landing helm charts for publish openg2p/openg2p-landing@${{ github.sha }}' | ||
add: './*.tgz ./index.yaml rancher/index.yaml' | ||
if: env.SKIP != 'TRUE' |