Skip to content

delete-extra-hostname #13

delete-extra-hostname

delete-extra-hostname #13

name: Delete Extra Hostnames
on:
repository_dispatch:
types: [delete-extra-hostname]
jobs:
update_values_file:
runs-on: ubuntu-latest
concurrency:
group: app-extra-hostname-group-${{ github.event.client_payload.appName }}
cancel-in-progress: false
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Update values.yaml
run: |
YAML_FILE="./pipelines/${{ github.event.client_payload.appName }}/values.yaml"
if [ -f "$YAML_FILE" ]; then
sed -i "/extraHostnames:/,/^[^ ]/ {/- \"${{ github.event.client_payload.hostname }}\"/d}" "$YAML_FILE"
sed -i '/extraHostnames:/{N;/extraHostnames:\n$/d;}' "$YAML_FILE"
else
echo "values.yaml not found for ${{ github.event.client_payload.appName }}"
exit 1
fi
- name: Commit and push changes
run: |
git config user.name "in-jun"
git config user.email "[email protected]"
git add .
git commit -m "Update values.yaml for ${{ github.event.client_payload.appName }}: Remove ${{ github.event.client_payload.hostname }}"
git push
- name: Trigger GoCD Pipeline
run: |
curl -X POST "https://admin-gocd.injunweb.com/go/api/pipelines/build-${{ github.event.client_payload.appName }}/schedule" \
-u "${{ secrets.GOCD_USERNAME }}:${{ secrets.GOCD_PASSWORD }}" \
-H "Accept: application/vnd.go.cd.v1+json" \
-H "X-GoCD-Confirm: true"