update infra for new setup
All checks were successful
Build, Test & Publish / Build (push) Successful in 29s
Build, Test & Publish / Build and Publish Container Image (push) Successful in 2m31s
Build, Test & Publish / Deploy to Infrastructure (push) Successful in 38s

This commit is contained in:
2025-11-12 13:57:44 +11:00
parent 45f2c61c17
commit 10e2eaa16b
5 changed files with 28 additions and 95 deletions

View File

@@ -46,7 +46,15 @@ jobs:
images: liamsgit.dev/LiamPietralla/code-snippets
tags: |
type=raw,value=latest
type=sha,value=${{ github.sha }}
# - name: Setup Docker Metadata
# id: meta
# uses: docker/metadata-action@v4
# with:
# images: liamsgit.dev/LiamPietralla/code-snippets
# tags: |
# type=raw,value=latest
# type=sha,value=${{ github.sha }}
- name: Login to Registry
uses: docker/login-action@v3
@@ -63,7 +71,7 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
deploy:
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
name: Deploy to Infrastructure
runs-on: ubuntu-latest
@@ -73,42 +81,21 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Write GitHub SSH Key to File
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
run: |
echo "$SSH_PRIVATE_KEY" > private.key
sudo chmod 400 private.key
- name: Write Ansible Inventory To File
env:
APP_HOST: ${{ secrets.APP_HOST }}
run: |
echo "[app]" > hosts.ini
echo "$APP_HOST" >> hosts.ini
- name: Install Ansible
run: |
sudo apt-add-repository ppa:ansible/ansible -y
sudo apt-get update -y
sudo apt-get install ansible -y
- name: Run Ansible Playbook to Configure Servers
run: |
export ANSIBLE_HOST_KEY_CHECKING=False # Disable host key checking
ansible-playbook infra/ansible/deploy-playbook.yml --private-key private.key --inventory hosts.ini
env:
APP_HOST: ${{ secrets.APP_HOST }}
REGISTRY_USERNAME: ${{ secrets.DOCKER_USERNAME }}
REGISTRY_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
# - name: Setup Nomad
# uses: hashicorp/setup-nomad@main
# with:
# nomad_version: '1.10.5'
- name: Setup Nomad
uses: hashicorp/setup-nomad@main
with:
nomad_version: '1.10.5'
# - name: Deploy Job to Nomad
# run: |
# nomad job run -var="version=${{ github.sha }}" infra/nomad/code-snippets.nomad.hcl
# env:
# NOMAD_ADDR: ${{ vars.NOMAD_ADDR }}
# NOMAD_TOKEN: ${{ secrets.NOMAD_TOKEN }}
- name: Deploy Job to Nomad
run: |
nomad job run infra/nomad/code-snippets.nomad.hcl
env:
NOMAD_ADDR: ${{ vars.NOMAD_ADDR }}
NOMAD_TOKEN: ${{ secrets.NOMAD_TOKEN }}