feat: move to forgejo actions
This commit is contained in:
parent
802b96cf1f
commit
c6e1381beb
3 changed files with 46 additions and 78 deletions
45
.forgejo/workflows/build.yml
Normal file
45
.forgejo/workflows/build.yml
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
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 }}
|
||||
62
.github/workflows/build.yml
vendored
62
.github/workflows/build.yml
vendored
|
|
@ -1,62 +0,0 @@
|
|||
name: Build and Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
schedule:
|
||||
- cron: '0 * * * *' # hourly
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Build application
|
||||
run: |
|
||||
docker build . -f Dockerfile -t "adriano_fyi:${GITHUB_SHA}"
|
||||
mkdir out
|
||||
docker save "adriano_fyi:${GITHUB_SHA}" -o "out/adriano_fyi-${GITHUB_SHA}.tar"
|
||||
- name: S3 Sync
|
||||
uses: jakejarvis/s3-sync-action@v0.5.1
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: "TWEELLU28RTD4IUQJXRT"
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.LINODE_SECRET_ACCESS_KEY }}
|
||||
AWS_S3_BUCKET: "adriano-fyi-static-site"
|
||||
AWS_REGION: "us-east-1"
|
||||
AWS_S3_ENDPOINT: "https://us-east-1.linodeobjects.com"
|
||||
SOURCE_DIR: "out"
|
||||
deploy:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Tailscale login
|
||||
uses: tailscale/github-action@v3
|
||||
with:
|
||||
version: 1.86.2
|
||||
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
|
||||
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
|
||||
tags: tag:github-action
|
||||
env:
|
||||
ADDITIONAL_ARGS: "--accept-dns"
|
||||
- name: Setup `nomad`
|
||||
uses: hashicorp/setup-nomad@main
|
||||
id: setup
|
||||
with:
|
||||
version: 1.11.3
|
||||
- name: Deploy nomad job
|
||||
run: |
|
||||
tailscale status
|
||||
# Discover active Nomad server via Tailscale
|
||||
NOMAD_SERVER_IP=$(tailscale status --json | jq -r '.Peer[] | select(.Tags[]? == "tag:nomad-server") | select(.Online == true) | .TailscaleIPs[0]' | head -n1)
|
||||
echo "Using Nomad server: $NOMAD_SERVER_IP"
|
||||
export NOMAD_ADDR="http://${NOMAD_SERVER_IP}:4646"
|
||||
nomad job run -var version=${GITHUB_SHA} -var secret_access_key=${{secrets.AWS_SECRET_ACCESS_KEY}} job.nomad.hcl
|
||||
env:
|
||||
NOMAD_TOKEN: ${{ secrets.NOMAD_TOKEN }}
|
||||
|
|
@ -2,10 +2,6 @@ variable "version" {
|
|||
type = string
|
||||
}
|
||||
|
||||
variable "secret_access_key" {
|
||||
type = string
|
||||
}
|
||||
|
||||
job "adriano-fyi" {
|
||||
datacenters = ["dc1"]
|
||||
namespace = "default"
|
||||
|
|
@ -23,19 +19,8 @@ job "adriano-fyi" {
|
|||
task "webserver" {
|
||||
driver = "docker"
|
||||
|
||||
artifact {
|
||||
source = "s3::https://us-east-1.linodeobjects.com/adriano-fyi-static-site/adriano_fyi-${var.version}.tar"
|
||||
options {
|
||||
aws_access_key_id = "6P583LDF5TH38MV4D1Y1"
|
||||
aws_access_key_secret = var.secret_access_key
|
||||
# Leave the archive in tar format
|
||||
archive = false
|
||||
}
|
||||
}
|
||||
|
||||
config {
|
||||
load = "adriano_fyi-${var.version}.tar"
|
||||
image = "adriano_fyi:${var.version}"
|
||||
image = "code.adriano.fyi/me/adriano.fyi:${var.version}"
|
||||
ports = ["http"]
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue