Added a reusable workflow to deploy a portainer stack #1
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 a stack on portainer | ||
| on: | ||
| workflow_call: | ||
| secrets: | ||
| portainer_stack_webhook: | ||
| required: true | ||
| type: string | ||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Connect to vpn (necessary to access portainer) | ||
| run: | | ||
| sudo apt install resolvconf | ||
| sudo apt install wireguard | ||
| echo "${{ secrets.WIREGUARD_CONF }}" > wg0.conf | ||
| sudo chmod 600 wg0.conf | ||
| echo "setting config" | ||
| sudo wg-quick up ./wg0.conf | ||
| - name: Trigger Portainer stack webhook | ||
| run: | | ||
| response=$(curl -X POST -w "%{http_code}" -o /dev/null -s ${{ secrets.portainer_stack_webhook }}) | ||
| if [ "$response" -ne 204 ]; then | ||
| echo "Error: POST request failed with status code $response" | ||
| exit 1 | ||
| fi | ||