Skip to content

Update .push-helm-chart.yml #2

Update .push-helm-chart.yml

Update .push-helm-chart.yml #2

name: .Deploys
on:
workflow_call:
inputs:
### Required
release:
description: Deployment release; usually PR number, test or prod
required: true
type: string
### Typical / recommended
autoscaling:
description: Autoscaling enabled or not for the deployments
required: false
type: string
default: true
environment:
description: Environment name; omit for PRs
required: false
type: string
tag:
description: Container tag; usually PR number
required: false
type: string
default: ${{ github.event.number }}
triggers:
description: Paths to trigger a deploy; omit=always; e.g. ('backend/' 'frontend/')
required: false
type: string
### Usually a bad idea / not recommended
directory:
description: 'Chart directory'
default: 'charts/${{ github.event.repository.name }}'
required: false
type: string
timeout-minutes:
description: 'Timeout minutes'
default: 10
required: false
type: number
values:
description: 'Values file'
default: 'values.yaml'
required: false
type: string
params:
description: 'Extra parameters to pass to helm upgrade'
default: ''
required: false
type: string
env:
repo_release: ${{ github.event.repository.name }}-${{ inputs.release }}
package_tag: ${{ inputs.tag }}
jobs:
deploys:
name: Helm
environment: ${{ inputs.environment }}
runs-on: ubuntu-22.04
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- uses: actions/checkout@v4
- name: Check Deployment Triggers
id: triggers
run: |
# Expand for trigger processing
# Always deploy if no triggers are provided
if [ -z "${{ inputs.triggers }}" ]; then
echo "Always deploy when no triggers are provided"
echo "triggered=true" >> $GITHUB_OUTPUT
exit 0
fi
# Deploy if changed files (git diff) match triggers
TRIGGERS=${{ inputs.triggers }}
git fetch origin ${{ github.event.repository.default_branch }}
while read -r check; do
for t in "${TRIGGERS[@]}"; do
if [[ "${check}" =~ "${t}" ]]; then
echo "Build triggered based on git diff"
echo -e "${t}\n --> ${check}"
echo "triggered=true" >> $GITHUB_OUTPUT
exit 0
fi
done
done < <(git diff origin/${{ github.event.repository.default_branch }} --name-only)
# If here skip deployment
echo "No triggers have fired, deployment skipped"
- name: Setup SSH for Target Repository
run: |
mkdir -p ~/.ssh
echo "${{ secrets.MANIFEST_REPO_DEPLOY_KEY }}" > ~/.ssh/id_rsa
echo "${{ secrets.MANIFEST_REPO_DEPLOY_KEY_PUB }}" > ~/.ssh/id_rsa.pub
chmod 600 ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa.pub
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
- name: Clone Target Repository
run: |
git clone git@github.com:${{ vars.GITOPS_REPO}}.git target-repo
cd target-repo
git checkout -b update-helm-chart
- name: Copy Helm Chart
run: |
cp -r ./charts/* ./helm-chart/
cd target-repo
- name: Commit and Push Changes
run: |
git add .
git commit -m "Update Helm chart"
git push --set-upstream origin update-helm-chart
- name: Create Pull Request
uses: repo-sync/pull-request@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_title: "Update Helm Chart"
pr_body: "Automated update of Helm chart"
destination_branch: "main"
source_branch: "update-helm-chart"
- name: Setup Git
run: |

Check failure on line 138 in .github/workflows/.push-helm-chart.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/.push-helm-chart.yml

Invalid workflow file

You have an error in your yaml syntax on line 138
git config --global user.name 'Barrett Falk'
git config --global user.email 'bfalk_t@salussystems.com'
- name: Clone Target Repository
env:
REMOTE_REPO_TOKEN: ${{ secrets.REMOTE_REPO_TOKEN }}
run: |
git clone https://x-access-token:$REMOTE_REPO_TOKEN@github.com/bcgov-c/nr-compliance-enforcement-cm.git target-repo
cd target-repo
git checkout -b update-helm-chart
- name: Copy Helm Chart
run: |
cp -r ./charts/* ./helm-chart/
cd target-repo
- name: Commit and Push Changes
env:
REMOTE_REPO_TOKEN: ${{ secrets.MANIFEST_REPO_DEPLOY_KEY }}
run: |
git add .
git commit -m "Update Helm chart"
git push --set-upstream origin update-helm-chart
- name: Create Pull Request
uses: repo-sync/pull-request@v2
with:
github_token: ${{ secrets.MANIFEST_REPO_DEPLOY_KEY }}
pr_title: "Update Helm Chart"
pr_body: "Automated update of Helm chart"
destination_branch: "main"
source_branch: "update-helm-chart"