Skip to content

Commit

Permalink
Upgrade CI
Browse files Browse the repository at this point in the history
  • Loading branch information
gdepuille committed Apr 7, 2024
1 parent eca6cd5 commit bf69da8
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -1,50 +1,60 @@
name: Docker publish
name: CI

on:
push:
# Publish `dev` as Docker `latest` image.
branches:
- dev
pull_request: {}
workflow_dispatch: {}

# Publish `v1.2.3` tags as releases.
tags:
- v*
jobs:
build:
runs-on: ubuntu-latest

# Run tests for any PRs.
pull_request:
steps:
- name: Checkout code
uses: actions/checkout@v4

jobs:
# Run tests.
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
# test:
# runs-on: ubuntu-latest
#
# steps:
# - uses: actions/checkout@v2
#
# - name: Run tests
# run: |
# if [ -f docker-compose.test.yml ]; then
# docker-compose --file docker-compose.test.yml build
# docker-compose --file docker-compose.test.yml run sut
# else
# docker build . --file Dockerfile
# fi

# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
push:
# Ensure test job passes before pushing image.
# needs: test
- name: Setup Node.js from 'package.json'
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
cache: 'yarn'

- name: Build
run: |
yarn install
yarn run lint
yarn run build
- uses: actions/upload-artifact@v4
if: github.event_name == 'push' && (github.ref_name == 'dev' || github.ref_type == 'tag')
with:
name: dist-${{ github.ref_name }}
path: dist
retention-days: 1

docker:
runs-on: ubuntu-latest
if: github.event_name == 'push'

needs: build
# Only publish dev branch and tags
if: github.event_name == 'push' && (github.ref_name == 'dev' || github.ref_type == 'tag')

permissions:
contents: read
packages: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get artifact from Build job
uses: actions/download-artifact@v4
with:
name: dist-${{ github.ref_name }}
path: dist

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

Expand Down Expand Up @@ -85,9 +95,9 @@ jobs:
# Docker buildx platforms
docker buildx ls
- name: Build and push
uses: docker/build-push-action@v3
- uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ env.IMAGE_ID }}:${{ env.VERSION }}
platforms: linux/amd64,linux/arm64
Expand Down
25 changes: 0 additions & 25 deletions .github/workflows/ci.yml

This file was deleted.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"author": "",
"license": "MIT",
"private": true,
"engine": {
"node": ">=18.14.0 <19.0.0",
"npm": ">=9.3.0"
},
"scripts": {
"lint": "eslint src --ext .ts",
"build": "tsc && cp src/conf.prod.json dist/conf.json && cp -r scripts dist/ && cp package.json dist/",
Expand Down

0 comments on commit bf69da8

Please sign in to comment.