From 9f9a699f62b21909219b64f00deac156c06a1438 Mon Sep 17 00:00:00 2001 From: Stefan Peters Date: Wed, 24 Jan 2024 11:14:57 +0100 Subject: [PATCH] Add GitHub workflows --- .github/workflows/docker.yml | 52 ++++++++++++++++++++++++++++++++ .github/workflows/gh-release.yml | 22 ++++++++++++++ .github/workflows/test.yml | 22 ++++++++++++++ .gitignore | 1 + 4 files changed, 97 insertions(+) create mode 100644 .github/workflows/docker.yml create mode 100644 .github/workflows/gh-release.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..06c7208 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,52 @@ +name: Publish Docker +on: + push: + branches: + - main + - dev + tags: + - v* + +# Adapted from: +# - https://github.com/docker/metadata-action#semver +# - https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-github-packages + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Docker Meta + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + - + name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Build and Push + uses: docker/build-push-action@v4 + with: + context: . + file: docker/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/gh-release.yml b/.github/workflows/gh-release.yml new file mode 100644 index 0000000..a237fc2 --- /dev/null +++ b/.github/workflows/gh-release.yml @@ -0,0 +1,22 @@ +name: GitHub Release + +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + +jobs: + github-release: + runs-on: ubuntu-latest + steps: + - name: Create GitHub release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Wikidata JSKOS ${{ github.ref }} + body: TODO + draft: true + prerelease: false diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..adee82c --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,22 @@ + +name: Test + +on: [push, pull_request] + +jobs: + test: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [ 18.x, 20.x ] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm ci + - run: npm test diff --git a/.gitignore b/.gitignore index 116fcf3..a378bb0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ cache/ .*/ +!.github/ .env config.json