45 lines
1.5 KiB
YAML
45 lines
1.5 KiB
YAML
name: Build and Deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
schedule:
|
|
- cron: '0 * * * *'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
packages: write
|
|
steps:
|
|
- name: Checkout
|
|
run: |
|
|
git clone https://oauth2:${{ secrets.GITEA_TOKEN }}@code.adriano.fyi/${{ github.repository }}.git .
|
|
git checkout ${{ github.sha }}
|
|
- name: Login to Forgejo registry
|
|
run: echo "${{ secrets.FORGEJO_TOKEN }}" | docker login code.adriano.fyi -u ${{ github.repository_owner }} --password-stdin
|
|
- name: Build and push image
|
|
run: |
|
|
docker build -f Dockerfile -t "code.adriano.fyi/me/adriano.fyi:${{ github.sha }}" .
|
|
docker push "code.adriano.fyi/me/adriano.fyi:${{ github.sha }}"
|
|
|
|
deploy:
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
run: |
|
|
git clone https://oauth2:${{ secrets.GITEA_TOKEN }}@code.adriano.fyi/${{ github.repository }}.git .
|
|
git checkout ${{ github.sha }}
|
|
- name: Install nomad
|
|
run: |
|
|
curl -fsSL https://releases.hashicorp.com/nomad/1.11.3/nomad_1.11.3_linux_amd64.zip -o nomad.zip
|
|
unzip nomad.zip
|
|
sudo mv nomad /usr/local/bin/nomad
|
|
rm nomad.zip
|
|
- name: Deploy nomad job
|
|
run: nomad job run -var "version=${{ github.sha }}" job.nomad.hcl
|
|
env:
|
|
NOMAD_ADDR: http://ncm-0.bison-lizard.ts.net:4646
|
|
NOMAD_TOKEN: ${{ secrets.NOMAD_TOKEN }}
|