feature ci/cd cleaning
This commit is contained in:
@@ -8,18 +8,21 @@ jobs:
|
|||||||
deploy:
|
deploy:
|
||||||
runs-on: node-ansible
|
runs-on: node-ansible
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Setup SSH key
|
- name: Setup SSH key
|
||||||
run: |
|
run: |
|
||||||
echo "${{ secrets.SSH_PRIVATE_KEY }}" > /tmp/id_fin
|
echo "${{ secrets.SSH_PRIVATE_KEY }}" > /tmp/id_fin
|
||||||
chmod 600 /tmp/id_fin
|
chmod 600 /tmp/id_fin
|
||||||
- name: Install Ansible collection
|
|
||||||
run: ansible-galaxy collection install community.docker
|
|
||||||
- name: Create inventory
|
- name: Create inventory
|
||||||
run: echo "${{ secrets.INVENTORY }}" > inventory.ini
|
run: echo "${{ secrets.INVENTORY }}" > inventory.ini
|
||||||
|
|
||||||
- name: Create secrets.yml
|
- name: Create secrets.yml
|
||||||
run: echo "${{ secrets.SECRETS }}" > secrets.yml
|
run: echo "${{ secrets.SECRETS }}" > secrets.yml
|
||||||
|
|
||||||
- name: Create .env file
|
- name: Create .env file
|
||||||
run: echo "${{ secrets.RUNNER_ENV }}" > .env
|
run: echo "${{ secrets.RUNNER_ENV }}" > .env
|
||||||
|
|
||||||
- name: Checkout only deploy.yml
|
- name: Checkout only deploy.yml
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
@@ -28,6 +31,7 @@ jobs:
|
|||||||
path: tmp-repo
|
path: tmp-repo
|
||||||
sparse-checkout: |
|
sparse-checkout: |
|
||||||
ansible/deploy.yml
|
ansible/deploy.yml
|
||||||
|
|
||||||
- name: Run Ansible playbook
|
- name: Run Ansible playbook
|
||||||
run: ansible-playbook -i inventory.ini tmp-repo/ansible/deploy.yml -e @secrets.yml -e env_file="$(pwd)/.env"
|
run: ansible-playbook -i inventory.ini tmp-repo/ansible/deploy.yml -e @secrets.yml -e env_file="$(pwd)/.env"
|
||||||
env:
|
env:
|
||||||
@@ -39,10 +43,13 @@ jobs:
|
|||||||
needs: deploy
|
needs: deploy
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Create .env file
|
- name: Create .env file
|
||||||
run: echo "${{ secrets.WEDDING_SITE_ENV }}" > .env
|
run: echo "${{ secrets.WEDDING_SITE_ENV }}" > .env
|
||||||
|
|
||||||
- name: Build image
|
- name: Build image
|
||||||
run: docker build -t back:latest -f docker/dockerfile .
|
run: docker build -t back:latest -f docker/dockerfile .
|
||||||
|
|
||||||
- name: Start docker-compose
|
- name: Start docker-compose
|
||||||
run: docker compose --env-file .env -f docker/docker-compose.yaml up -d
|
run: docker compose --env-file .env -f docker/docker-compose.yaml up -d
|
||||||
|
|
||||||
@@ -3,10 +3,18 @@
|
|||||||
vars:
|
vars:
|
||||||
env_file: $(pwd)/.env
|
env_file: $(pwd)/.env
|
||||||
tasks:
|
tasks:
|
||||||
|
|
||||||
|
- name: Install wget
|
||||||
|
apt:
|
||||||
|
name: wget
|
||||||
|
state: present
|
||||||
|
update_cache: yes
|
||||||
|
|
||||||
- name: Install Docker
|
- name: Install Docker
|
||||||
shell: curl -fsSL https://get.docker.com | sh
|
shell: curl -fsSL https://get.docker.com | sh
|
||||||
args:
|
args:
|
||||||
creates: /usr/bin/docker
|
creates: /usr/bin/docker
|
||||||
|
|
||||||
- name: Ensure /opt/infra exists
|
- name: Ensure /opt/infra exists
|
||||||
file:
|
file:
|
||||||
path: /opt/infra
|
path: /opt/infra
|
||||||
@@ -14,6 +22,7 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: '0755'
|
mode: '0755'
|
||||||
|
|
||||||
- name: Copy .env to remote
|
- name: Copy .env to remote
|
||||||
copy:
|
copy:
|
||||||
src: "{{ env_file }}"
|
src: "{{ env_file }}"
|
||||||
@@ -22,15 +31,18 @@
|
|||||||
group: root
|
group: root
|
||||||
mode: '0600'
|
mode: '0600'
|
||||||
|
|
||||||
|
- name: Download nginx
|
||||||
|
shell: wget -O /opt/infra/nginx.yaml "{{ URL for docker-compose nginx }}"
|
||||||
|
args:
|
||||||
|
creates: /opt/infra/nginx.yaml
|
||||||
|
|
||||||
- name: Download node-docker.yaml
|
- name: Download node-docker.yaml
|
||||||
shell: wget -O /opt/infra/node-docker.yaml "{{ gitea_instance_url }}"
|
shell: wget -O /opt/infra/node-docker.yaml "{{ gitea_instance_url }}"
|
||||||
|
args:
|
||||||
|
creates: /opt/infra/node-docker.yaml
|
||||||
|
|
||||||
# - name: Start docker compose via module
|
- name: Start node-docker
|
||||||
# community.docker.docker_compose_v2:
|
|
||||||
# project_src: /opt/infra
|
|
||||||
# files:
|
|
||||||
# - node-docker.yaml
|
|
||||||
# state: present
|
|
||||||
# restarted: true
|
|
||||||
- name: Start docker compose
|
|
||||||
shell: docker-compose -f /opt/infra/node-docker.yaml up -d
|
shell: docker-compose -f /opt/infra/node-docker.yaml up -d
|
||||||
|
|
||||||
|
- name: Start nginx
|
||||||
|
shell: docker-compose -f /opt/infra/nginx.yaml up -d
|
||||||
|
|||||||
Reference in New Issue
Block a user