Skip to content

Commit

Permalink
ci workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienR1 committed Oct 29, 2023
1 parent de26129 commit 816cafa
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 1 deletion.
77 changes: 77 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: CI

on:
push:
pull_request:

jobs:
check-web:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./web
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: "18.x"
cache: "npm"
cache-dependency-path: ./web/package-lock.json
- name: Install
run: npm ci
- name: Lint
run: npm run lint
- name: Test
run: npm run test
- name: Build
run: npm run build
- name: Save built app
uses: actions/upload-artifact@v3
with:
name: web
path: ./web/dist/
retention-days: 1
if-no-files-found: error

check-server:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./server
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "1.21.x"
- name: Vet
run: go vet ./...
- name: Test
run: go test ./...
- name: Build
run: go build ./cmd/server/main.go
- name: Save built ./server
uses: actions/upload-artifact@v3
with:
name: server
path: ./server/main
retention-days: 1
if-no-files-found: error

archive:
if: github.ref == 'refs/heads/master'
needs: [check-web, check-server]
runs-on: ubuntu-latest
steps:
- run: mkdir public
- uses: actions/download-artifact@v3
with:
name: web
path: ./public/
- uses: actions/download-artifact@v3
with:
name: server
path: .
- uses: actions/upload-artifact@v3
with:
name: moneymanager2
path: ./
38 changes: 38 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Publish

on:
workflow_run:
workflows: [CI]
types: [completed]
branches: [master]

jobs:
publish:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Download artifact
uses: actions/github-script@v6
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "moneymanager2"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/moneymanager2.zip`, Buffer.from(download.data));
- run: unzip moneymanager2.zip
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
push: origin releases --set-upstream --force
3 changes: 2 additions & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"dev": "vite --host",
"build": "vite build",
"serve": "vite preview",
"lint": "tsc --noEmit"
"lint": "tsc --noEmit",
"test": "echo \"TODO\""
},
"license": "MIT",
"devDependencies": {
Expand Down

0 comments on commit 816cafa

Please sign in to comment.