Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
connorhsm committed Oct 28, 2024
1 parent 4daad21 commit 7965da6
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 77 deletions.
109 changes: 109 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Deploy Junior

on:
push:
branches:
- main

concurrency:
group: deploy-group

jobs:
build-release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- name: Get version
id: version
run: |
version=$(git describe --tags --abbrev=0)
next_version=$(($version + 1))
echo "version=$next_version" >> $GITHUB_OUTPUT
- name: Collect Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/twohoursonelife/junior
tags: |
type=raw,value=${{ steps.version.outputs.version }}
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}

# TODO: Reconsider building this into the image itself since restructure
- name: Add version.txt
run: echo ${{ steps.version.outputs.version }} > version.txt

- name: Build and push
uses: docker/build-push-action@v6
with:
context: . # Intentionally using Path context to include version.txt
push: true
tags: ${{ steps.meta.outputs.tags }}, ghcr.io/twohoursonelife/junior:latest
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Create release
uses: ncipollo/release-action@v1
with:
generateReleaseNotes: true
makeLatest: true
tag: ${{ steps.version.outputs.version }}

deploy-commands:
runs-on: ubuntu-latest
environment: prod-commands
steps:
- uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install dependencies
run: npm ci

- name: Deploy commands
run: node deploy-commands.js
env:
PROD_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }}

deploy:
runs-on: ubuntu-latest
needs:
- build-release
environment: prod
steps:
- uses: actions/checkout@v4

# Deploy commands
- uses: oven-sh/setup-bun@v2

- name: Install dependencies
run: bun install --frozen-lockfile

- name: Deploy commands
run: bun run deploy-commands.js
env:
PROD_TOKEN: ${{ secrets.BOT_TOKEN }}

# Deploy to Fly
- uses: superfly/flyctl-actions/setup-flyctl@master

- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
20 changes: 10 additions & 10 deletions .github/workflows/fly-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
# branches:
# - main
# jobs:
# deploy:
# name: Deploy app
# runs-on: ubuntu-latest
# concurrency: deploy-group # optional: ensure only one action runs at a time
# steps:
# - uses: actions/checkout@v4
# - uses: superfly/flyctl-actions/setup-flyctl@master
# - run: flyctl deploy --remote-only
# env:
# FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
deploy:
name: Deploy app
runs-on: ubuntu-latest
concurrency: deploy-group # optional: ensure only one action runs at a time
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
67 changes: 0 additions & 67 deletions .github/workflows/release.yml

This file was deleted.

2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ COPY package.json bun.lockb ./
RUN bun install --frozen-lockfile --production
COPY . .

RUN ls

CMD ["bun", "run", "junior.js"]
3 changes: 3 additions & 0 deletions bash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version="1"
next_version=$(($version + 1))
echo $next_version
2 changes: 2 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ swap_size_mb = 512
[[restart]]
policy = "on-failure"

# Release command, deploy commands

[[vm]]
size = "shared-cpu-1x"
memory = "256mb"

0 comments on commit 7965da6

Please sign in to comment.