Merge pull request #9 from bhumi46/master #2
This file contains hidden or 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
| name: Deploy Mosip services of mosip using Helmsman | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| mode: | |
| description: "Choose Helmsman mode: dry-run or apply" | |
| required: true | |
| default: "dry-run" | |
| type: choice | |
| options: | |
| - dry-run | |
| - apply | |
| push: | |
| paths: | |
| - Helmsman/dsf/mosip-dsf.yaml | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v2 | |
| - name: Set Default Mode | |
| run: | | |
| if [ -z "${{ github.event.inputs.mode }}" ]; then | |
| echo "mode=apply" >> $GITHUB_ENV | |
| else | |
| echo "mode=${{ github.event.inputs.mode }}" >> $GITHUB_ENV | |
| fi | |
| - name: Setup ufw firewall | |
| run: | | |
| sudo ufw enable | |
| sudo ufw allow ssh | |
| sudo ufw allow 51820/udp | |
| sudo ufw status | |
| - name: Install WireGuard | |
| run: sudo apt-get install -y wireguard | |
| - name: Configure WireGuard | |
| run: | | |
| echo "${{ secrets.CLUSTER_WIREGUARD_WG0 }}" | sudo tee /etc/wireguard/wg0.conf | |
| - name: Start WireGuard | |
| run: | | |
| sudo chmod 600 /etc/wireguard/wg0.conf | |
| sudo chmod 700 /etc/wireguard/ | |
| sudo chmod 644 /lib/systemd/system/wg-quick@.service | |
| sudo systemctl daemon-reload | |
| sudo wg-quick up wg0 | |
| sudo wg show wg0 | |
| - name: Setup Helm | |
| run: | | |
| curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | |
| sudo chmod 700 get_helm.sh | |
| sudo ./get_helm.sh | |
| helm version --client | |
| - name: Install Helmsman | |
| run: | | |
| curl -L https://github.com/Praqma/helmsman/releases/download/v3.17.1/helmsman_3.17.1_linux_amd64.tar.gz -o helmsman.tar.gz | |
| tar xzf helmsman.tar.gz | |
| sudo mv helmsman /usr/local/bin | |
| - name: Initiate helmsman to apply the DSF configurations. | |
| env: | |
| KUBECONFIG: ${{ secrets.KUBECONFIG }} | |
| run: | | |
| curl -L https://istio.io/downloadIstio | ISTIO_VERSION=1.22.0 TARGET_ARCH=x86_64 sh - | |
| export PATH=$PWD/istio-1.22.0/bin:$PATH | |
| curl -LO https://dl.k8s.io/release/v1.31.3/bin/linux/amd64/kubectl | |
| chmod +x kubectl | |
| mkdir -p ~/.local/bin | |
| mv ./kubectl ~/.local/bin/kubectl | |
| kubectl version --client | |
| mkdir -p $HOME/.kube | |
| echo "${{ secrets.KUBECONFIG }}" > $HOME/.kube/config | |
| chmod 400 $HOME/.kube/config | |
| export KUBECONFIG=$HOME/.kube/config | |
| kubectl config view | |
| kubectl get nodes | |
| export HOME="/home/runner/work/infra/infra" | |
| export WORKDIR="$HOME/Helmsman" | |
| helmsman --debug --${{ env.mode }} -f $WORKDIR/dsf/mosip-dsf.yaml | |
| workflow-caller: | |
| runs-on: ubuntu-latest | |
| needs: deploy | |
| steps: | |
| - name: Trigger helmsman testrigs workflow via API | |
| if: ${{ github.event_name == 'workflow_dispatch' }} | |
| env: | |
| GITHUB_REPO: ${{ github.repository }} | |
| GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} | |
| BRANCH: ${{ github.ref_name }} | |
| run: | | |
| curl -X PATCH \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Authorization: Bearer $GITHUB_TOKEN" \ | |
| https://api.github.com/repos/$GITHUB_REPO \ | |
| -d '{"default_branch":"'"$BRANCH"'"}' | |
| curl -X POST \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Authorization: Bearer $GITHUB_TOKEN" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| https://api.github.com/repos/$GITHUB_REPO/actions/workflows/helmsman_testrigs.yml/dispatches \ | |
| -d '{"ref":"'"$BRANCH"'","inputs":{"mode":"apply"}}' |