Skip to content

Commit

Permalink
Add GitHub Actions workflow for building and pushing Docker images (#6)
Browse files Browse the repository at this point in the history
* Add GitHub Actions workflow for caching npm dependencies and building and pushing Docker images
  • Loading branch information
icereed authored Oct 4, 2024
1 parent c7b5c6a commit 199e141
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 1 deletion.
84 changes: 84 additions & 0 deletions .github/workflows/docker-build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Build and Push Docker Images

on:
push:
branches:
- main
tags:
- 'v*.*.*'
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.22

- name: Install dependencies
run: go mod download

- name: Run Go tests
run: go test ./...

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 20

- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install frontend dependencies
run: npm install
working-directory: web-app

- name: Run frontend tests
run: npm test
working-directory: web-app

build-and-push:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

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

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Build and push Docker images
id: docker_build
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
icereed/paperless-gpt:unreleased
${{ github.ref == 'refs/heads/main' && 'icereed/paperless-gpt:unreleased' }}
${{ github.ref_type == 'tag' && 'icereed/paperless-gpt:latest' }}
${{ github.ref_type == 'tag' && 'icereed/paperless-gpt:${{ github.ref_name }}' }}
3 changes: 2 additions & 1 deletion web-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
"preview": "vite preview",
"test": "echo \"TODO\""
},
"dependencies": {
"@headlessui/react": "^2.1.8",
Expand Down

0 comments on commit 199e141

Please sign in to comment.