feat: caddy auto DNS #160
Workflow file for this run
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
# This is a basic workflow to help you get started with Actions | |
name: Ansible Docker Swarm Digital Ocean | |
# Controls when the workflow will run | |
on: | |
pull_request: | |
# Only run when targeting main | |
branches: | |
- main | |
types: | |
- opened | |
- edited | |
- ready_for_review | |
- synchronize | |
paths: | |
- 'ansible/**' | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
validate: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v3 | |
- name: Run ansible-lint | |
# replace `main` with any valid ref, or tags like `v6` | |
uses: ansible-community/ansible-lint-action@v6.0.2 | |
with: | |
args: "ansible" | |
run-playbook: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# The validate Job need to be sucessfull | |
needs: [ validate ] | |
# The deployement environnement thus provides the secrets for that env | |
environment: digitalocean | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.9 | |
cache: 'pip' # caching pip dependencies | |
- name: Install dependencies Including Ansible | |
run: | | |
python -m pip install --upgrade pip | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi | |
- name: write inventory to file | |
env: | |
INVENTORY: ${{ secrets.ANSIBLE_INVENTORY }} | |
run: 'echo "$INVENTORY" > inventory' | |
- name: Install SSH key | |
uses: shimataro/ssh-key-action@v2 | |
with: | |
key: ${{ secrets.ANSIBLE_SSH_KEY }} | |
name: id_rsa # optional | |
known_hosts: ${{ secrets.ANSIBLE_KNOWN_HOSTS }} | |
# config: ${{ secrets.CONFIG }} # ssh_config; optional | |
if_key_exists: fail # replace / ignore / fail; optional (defaults to fail) | |
- name: run playbook | |
run: | | |
ansible-playbook -i inventory ansible/docker-swarm-portainer-caddy.yml | |
env: | |
# This is used by caddy to authenticate users | |
CADDY_GITHUB_CLIENT_ID: ${{ secrets.CADDY_GITHUB_CLIENT_ID }} | |
CADDY_GITHUB_CLIENT_SECRET: ${{ secrets.CADDY_GITHUB_CLIENT_SECRET }} | |
CADDY_JWT_SHARED_KEY: ${{ secrets.CADDY_JWT_SHARED_KEY }} | |
# This is used by caddy to configure dns records | |
CADDY_DIGITALOCEAN_API_TOKEN: ${{ secrets.CADDY_DIGITALOCEAN_API_TOKEN }} |