Skip to content

ci: add shared volume #113

ci: add shared volume

ci: add shared volume #113

Workflow file for this run

name: CI
on:
push:
branches:
- main
env:
NODE_VERSION: 18
PNPM_VERSION: 8
jobs:
release:
runs-on: ubuntu-latest
services:
mariadb:
image: mariadb:10.4
env:
MYSQL_ROOT_PASSWORD: root
volumes:
- /tmp:/tmp
ports:
- 127.0.0.1:3307:3306
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- id: pnpm-cache
shell: bash
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-pnpm-store-
- name: Setup system config
run: git config --global user.email "datatruck@localhost" && git config --global user.name "Datatruck"
- name: Install dependencies
run: pnpm install
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Install system dependencies
run: sudo apt-get install restic git tar pigz -y
- name: Update restic
run: sudo restic self-update
- name: Test
run: pnpm test
- name: Build
run: pnpm build
- name: Compose
run: pnpm compose
- name: Create release pull request or publish to npm
id: changesets
uses: changesets/action@v1
with:
commit: "chore: update versions"
title: Update versions
publish: pnpm exec changeset publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- id: changesets_meta
name: Build changesets meta
uses: actions/github-script@v6
env:
PUBLISHED_PACKAGES: ${{ steps.changesets.outputs.publishedPackages }}
with:
script: |-
const output = {};
const published = JSON.parse(process.env.PUBLISHED_PACKAGES);
output['@datatruck/cli:published'] = false;
published.forEach(({ name, version }) => {
const vars = { version, published: true };
Object.keys(vars).forEach(n => output[`${name}:${n}`] = vars[n]);
});
console.info(output);
Object.keys(output).forEach(k => core.setOutput(k, output[k]));
- id: image_meta
name: Build image metadata
uses: docker/metadata-action@v4
if: steps.changesets_meta.outputs['@datatruck/cli:version'] != ''
with:
images: ghcr.io/${{ github.repository }}
tags: |-
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}},value=v${{ steps.changesets_meta.outputs['@datatruck/cli:version'] }}
type=semver,pattern={{major}}.{{minor}},value=v${{ steps.changesets_meta.outputs['@datatruck/cli:version'] }}
type=semver,pattern={{major}},value=v${{ steps.changesets_meta.outputs['@datatruck/cli:version'] }}
type=sha
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login Docker
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and publish image
uses: docker/build-push-action@v3
with:
tags: ${{ steps.image_meta.outputs.tags }}
labels: ${{ steps.image_meta.outputs.labels }}
push: ${{ steps.changesets_meta.outputs['@datatruck/cli:published'] }}