Skip to content

Commit

Permalink
feat: deployments and stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
SrIzan10 committed Sep 2, 2023
1 parent 7ac7ee4 commit 88463be
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 11 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Log in to Sr Izan's container registry
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
registry: containers.srizan.dev
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: containers.srizan.dev/vinci
tags: latest

- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Emit a webhook to the server
env:
AUTH_HEADER: ${{ secrets.WHSERVER_TOKEN }}
run: |
curl -X POST \
-H "Authorization: Bearer $AUTH_HEADER" \
https://webhooks.srizan.dev/hooks/automata
8 changes: 4 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import bodyParser from 'body-parser';
import 'dotenv/config';
import { execa } from 'execa';
import { validateJsonWebhook } from './util/validateJsonWebhook.js';
import babashkaScripts from './babashka/scripts.json' assert { type: 'json' }
import babashkaScripts from './babashka/scripts.json' assert { type: 'json' };

const app = express()
app.use(bodyParser.json())
Expand All @@ -28,10 +28,10 @@ app.post('/wh/updateDocsJson', async (req, res) => {
error: 'Token valid, but ignoring action...'
})
}
const command = await execa('bash', ['scripts/updateDocsJson.sh', process.env.GHTOKEN!], { shell: true })
execa('bash', ['scripts/updateDocsJson.sh', process.env.GHTOKEN!, process.env.EMAIL!], { shell: true })
res.send({
success: command.exitCode === 0 ? true : false,
cmdoutput: command.stdout
success: true,
message: "command is running"
})
})

Expand Down
15 changes: 11 additions & 4 deletions scripts/updateDocsJson.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
#!/bin/bash

cd repos/sern-community
git checkout -b docsjson
git pull
# merge all changes from main to docsjson to be updated
git checkout docsjson
git merge main
git -c user.name="sern bot" -c user.email="$2" commit -m "chore: merge changes from main"
git push https://sernbot:$1@github.com/sern-handler/sern-community.git

cd ..
cd website
npm run typedoc-json
cd ..
cd sern-community
git add .
git commit -m "chore: update typedoc"
git -c user.name="sern bot" -c user.email="$2" commit -m "chore: update typedoc"
git push https://sernbot:$1@github.com/sern-handler/sern-community.git
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $1"\
-H "Authorization: Bearer $1" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/sern-handler/sern-community/pulls \
-d '{"title":"chore: update typedoc","body":"automated typedoc update (as of the new latest update in the handler)","head":"docsjson","base":"main"}'
-d '{"title":"chore: update typedoc","body":"automated typedoc update (as of the new latest update in the handler)","head":"docsjson","base":"main"}'
git checkout main
6 changes: 3 additions & 3 deletions util/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ npm i > /dev/null 2>&1
cd ..
echo " done"
# handler
echo -ne "- handler"
echo -ne "- handler (using yarn)"
cd sernHandlerV2
npm i > /dev/null 2>&1
yarn > /dev/null 2>&1
cd ..
echo " done"
# discord bot
echo -ne "- discord bot (using yarn)"
cd sern-community
yarn install > /dev/null 2>&1
yarn > /dev/null 2>&1
cd ..
echo " done"

Expand Down

0 comments on commit 88463be

Please sign in to comment.