fix: PORT/HOST env vars + relative path??? #19
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
name: CI | |
concurrency: | |
group: ci | |
cancel-in-progress: true | |
on: | |
push: | |
branches: [ main ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Ensure latest version of git. | |
- name: Ensure latests version of git | |
run: | | |
sudo apt-get install -y software-properties-common \ | |
&& sudo apt-get update \ | |
&& sudo add-apt-repository -y ppa:git-core/ppa \ | |
&& sudo apt-get update \ | |
&& sudo apt-get install -y git | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
# Builds docker images and pushes them to GHCR | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ secrets.GHCR_USER }} | |
password: ${{ secrets.GHCR_TOKEN }} | |
- name: Build and push prod image | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
context: . | |
tags: ghcr.io/alanpq/website:latest, ghcr.io/alanpq/website:${{ github.sha }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
deploy: | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy via ansible. | |
uses: alanpq/ansible-action@main | |
with: | |
tags: "web" | |
playbook: alanp.yml | |
host: ${{ secrets.HOST }} | |
user: ${{ secrets.USER }} | |
ssh_key: ${{ secrets.SSH_KEY }} | |
directory: ${{ secrets.DIRECTORY }} | |
vault_pass: ${{ secrets.VAULT_PASS }} | |