1+ name : Build the docker images and deploy
2+ on :
3+ push :
4+ branches : [ "master" ]
5+ pull_request :
6+ branches : [ "master" ]
7+ jobs :
8+ build_and_push_images :
9+ runs-on : ubuntu-latest
10+ steps :
11+ - uses : actions/checkout@v3
12+ - name : Log into dockerhub
13+ run : echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
14+ - name : Build the Authoritative DNS image
15+ run : |
16+ cd authdns
17+ docker build -t dominikmatic/dddns-authdns:latest .
18+ - name : Build the API server image
19+ run : |
20+ cd apiserver
21+ docker build -t dominikmatic/dddns-apiserver:latest .
22+ - name : Push the authdns Docker image
23+ run : docker push dominikmatic/dddns-authdns:latest
24+ - name : Push the apiserver Docker image
25+ run : docker push dominikmatic/dddns-apiserver:latest
26+ deploy :
27+ needs : build_and_push_images
28+ runs-on : ubuntu-latest
29+ steps :
30+ - uses : actions/checkout@v3
31+ - name : template .env file
32+ run : |
33+ cat <<EOF > ./deployment/files/deploy/.env
34+ DB_USER=${{ secrets.DB_USER }}
35+ DB_PASS=${{ secrets.DB_PASS }}
36+ DB_HOST=${{ secrets.DB_HOST }}
37+ DB_NAME=${{ secrets.DB_NAME }}
38+ AUTH_TOKEN=${{ secrets.AUTH_TOKEN }}
39+ EOF
40+
41+ - name : Run ansible playbook
42+ uses : dawidd6/action-ansible-playbook@v2
43+ with :
44+ # Required, playbook filepath
45+ playbook : deployment/deploy.yml
46+ # Optional, SSH private key
47+ key : ${{secrets.ANSIBLE_PRIVATE_KEY}}
48+ # Optional, literal inventory file contents
49+ inventory : |
50+ [dddns_servers]
51+ 3.73.187.39
52+ # Optional, SSH known hosts file content
53+ known_hosts : |
54+ 3.73.187.39 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFPYJDOesJo7cyobs6S4mjhhud13BpmG0GnLZ/Q8yf7Y
55+ options : |
56+ -u ansible
0 commit comments