Skip to content

Commit

Permalink
ci: add github action
Browse files Browse the repository at this point in the history
  • Loading branch information
KirioXX committed May 5, 2024
1 parent 849282a commit 9f8c186
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
REDISHOST=localhost
REDISPORT=6379
OMNIVORE_API_KEY=
OMNIVORE_USER_ID=
MISTRAL_API_KEY=
69 changes: 69 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.

name: Publish Docker image

on:
push:
branches:
- main

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
push_to_registries:
name: Push Docker image to multiple registries
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: |
kirioxx/omnivore-label-bot
ghcr.io/${{ github.repository }}
- name: Build and push Docker images
id: push
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build

FROM base
ARG PORT
ARG REDISHOST
ARG REDISPORT
ARG OMNIVORE_API_KEY
ARG OMNIVORE_USER_ID
ARG MISTRAL_API_KEY

ENV PORT=${PORT}
ENV REDISHOST=${REDISHOST}
ENV REDISPORT=${REDISPORT}
ENV OMNIVORE_API_KEY=${OMNIVORE_API_KEY}
Expand All @@ -32,4 +34,4 @@ RUN pnpm install -g pm2
EXPOSE ${PORT}
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD curl -f http://localhost:${PORT}/health || exit 1
USER node
CMD ["pm2-runtime", "start", "dist/main.js"]
CMD ["pm2-runtime", "start", "dist/src/main.js"]
42 changes: 37 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,47 @@
version: '3.7'
services:
redis:
image: redis:alpine
restart: always
ports:
- '6379:6379'
volumes:
- redis-data:/data
networks:
- omnivore-bot-network
- app-network
app:
build: .
ports:
- '3000:3000'
image: kirioxx/omnivore-label-bot:main
depends_on:
- redis
- tailscale-app
environment:
- REDIS_HOST=redis
- REDIS_PORT=6379
- OMNIVORE_API_KEY=${OMNIVORE_API_KEY}
- OMNIVORE_USER_ID=${OMNIVORE_USER_ID}
- MISTRAL_API_KEY=${MISTRAL_API_KEY}
networks:
- omnivore-bot-network
- app-network
network_mode: service:tailscale-app
# tailscale-app:
# image: tailscale/tailscale:latest
# hostname: tailscale-app
# environment:
# - TS_AUTHKEY=tskey-auth-kTsyEpBbK211CNTRL-cimMrq5Zke4xvmUw45pke4YDhAf4ZsDd
# - TS_EXTRA_ARGS=--advertise-tags=tag:container
# - TS_STATE_DIR=/var/lib/tailscale
# - TS_USERSPACE=false
# volumes:
# - ${PWD}/tailscale-app/state:/var/lib/tailscale
# - /dev/net/tun:/dev/net/tun
# cap_add:
# - net_admin
# - sys_module
# restart: unless-stopped

volumes:
redis-data:

networks:
app-network:
driver: bridge

0 comments on commit 9f8c186

Please sign in to comment.