Skip to content

Commit

Permalink
ci: add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ebuildy committed Oct 19, 2022
1 parent c013942 commit 7e8ccb0
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 79 deletions.
81 changes: 2 additions & 79 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,12 @@ jobs:
- run: npm ci
working-directory: front

# - run: npm test
# working-directory: front
- run: npm test
working-directory: front

- run: npm run build
working-directory: front

- name: upload artifacts
uses: actions/upload-artifact@v2
with:
name: front
path: front/build

back:

runs-on: ubuntu-latest
Expand Down Expand Up @@ -68,74 +62,3 @@ jobs:

- run: npm run build
working-directory: back

- name: upload artifacts
uses: actions/upload-artifact@v2
with:
name: back
path: back/dist

- name: Restore back deps
uses: actions/cache@v3
with:
path: back/node_modules
key: back/package-lock.json

docker:
runs-on: ubuntu-latest

needs: [front, back]

env:
REGISTRY: ghcr.io
IMAGE_NAME: datatok/gui

steps:

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

- name: Login to DockerHub
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- uses: actions/checkout@v2

- name: Download front artifact
uses: actions/download-artifact@v2
with:
name: front
path: front/build

- name: Download back artifact
uses: actions/download-artifact@v2
with:
name: back
path: back/dist

- name: Restore back deps
uses: actions/cache@v3
with:
path: back/node_modules
key: back/package-lock.json

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: packages/docker/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILDKIT_INLINE_CACHE=1
140 changes: 140 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Build apps and Docker image

on:
push:
tags:
- 'v*'

jobs:
front:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: front/package-lock.json

- run: npm ci
working-directory: front

# - run: npm test
# working-directory: front

- run: npm run build
working-directory: front

- name: upload artifacts
uses: actions/upload-artifact@v2
with:
name: front
path: front/build

back:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: back/package-lock.json

- run: npm ci
working-directory: back

# - run: npm test
# working-directory: back

- run: npm run build
working-directory: back

- name: upload artifacts
uses: actions/upload-artifact@v2
with:
name: back
path: back/dist

- name: Restore back deps
uses: actions/cache@v3
with:
path: back/node_modules
key: back/package-lock.json

docker:
runs-on: ubuntu-latest

needs: [front, back]

env:
REGISTRY: ghcr.io
IMAGE_NAME: datatok/gui

steps:

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

- name: Login to DockerHub
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- uses: actions/checkout@v2

- name: Download front artifact
uses: actions/download-artifact@v2
with:
name: front
path: front/build

- name: Download back artifact
uses: actions/download-artifact@v2
with:
name: back
path: back/dist

- name: Restore back deps
uses: actions/cache@v3
with:
path: back/node_modules
key: back/package-lock.json

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: packages/docker/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILDKIT_INLINE_CACHE=1

0 comments on commit 7e8ccb0

Please sign in to comment.