This repository has been archived on 2022-10-07. You can view files and clone it, but cannot push or open issues or pull requests.
skynet-webportal/.github/workflows/ci_release.yml

175 lines
6.0 KiB
YAML
Raw Normal View History

2022-04-07 20:44:57 +00:00
name: CI and Release
on:
2022-04-07 20:44:57 +00:00
push:
schedule:
# Run daily at 1:15am
- cron: "15 1 * * *"
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
version:
# Friendly description to be shown in the UI instead of 'name'
description: "Semver type of new version (major / minor / patch)"
# Input has to be provided for the workflow to run
required: true
type: choice
options:
- patch
- minor
- major
jobs:
2022-04-05 13:43:46 +00:00
# Determine what the js changes are
js-changes:
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.filter.outputs.changes }}
steps:
# Use paths-filter to determine which paths have changes
# https://github.com/dorny/paths-filter
- uses: dorny/paths-filter@v2
id: filter
with:
# Format of key: value. When there is a change detected in value, the
# key will be returned in the output.
filters: |
packages/dashboard: packages/dashboard/**
2022-04-05 13:43:46 +00:00
packages/dashboard-v2: packages/dashboard-v2/**
packages/dnslink-api: packages/dnslink-api/**
packages/handshake-api: packages/handshake-api/**
packages/health-check: packages/health-check/**
packages/website: packages/website/**
2022-04-07 20:38:26 +00:00
# Run the prettier lint if there are changes to any of the js packages
prettier:
2022-04-05 13:43:46 +00:00
needs: js-changes
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
2022-04-05 13:43:46 +00:00
working-directory: ${{ fromJSON(needs.js-changes.outputs.packages) }}
steps:
- uses: actions/checkout@v3
2022-04-05 13:43:46 +00:00
- name: Run JS-Lint Action
2022-04-07 20:38:26 +00:00
uses: SkynetLabs/.github/.github/actions/prettier@master
with:
working-directory: ${{ matrix.working-directory }}
2022-04-07 20:38:26 +00:00
# Run the eslint if there were changes to the dashboard packages
eslint:
needs: js-changes
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
working-directory: ${{ fromJSON(needs.js-changes.outputs.packages) }}
steps:
- uses: actions/checkout@v3
- name: Run yarn next lint on packages/dashboard
uses: ./.github/actions/node-action
2022-04-07 20:39:30 +00:00
if: ${{ matrix.working-directory == 'packages/dashboard' }}
2022-04-07 20:38:26 +00:00
with:
working-directory: ${{ matrix.working-directory }}
node-action: yarn next lint
- name: Run yarn lint on packages/dashboard-v2
uses: ./.github/actions/node-action
2022-04-07 20:39:30 +00:00
if: ${{ matrix.working-directory == 'packages/dashboard-v2' }}
2022-04-07 20:38:26 +00:00
with:
working-directory: ${{ matrix.working-directory }}
node-action: yarn lint
2022-04-07 20:44:57 +00:00
# Determine what the dockerfile changes are
dockerfile-changes:
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.filter.outputs.changes }}
steps:
# Use paths-filter to determine which paths have changes
# https://github.com/dorny/paths-filter
- uses: dorny/paths-filter@v2
id: filter
with:
# Format of key: value. When there is a change detected in value, the
# key will be returned in the output.
filters: |
docker/nginx/Dockerfile: docker/nginx/Dockerfile
docker/sia/Dockerfile: docker/sia/Dockerfile
packages/dashboard/Dockerfile: packages/dashboard/Dockerfile
packages/dnslink-api/Dockerfile: packages/dnslink-api/Dockerfile
packages/handshake-api/Dockerfile: packages/handshake-api/Dockerfile
packages/health-check/Dockerfile: packages/health-check/Dockerfile
packages/website/Dockerfile: packages/website/Dockerfile
# Run the hadolint dockefile lint if there are changes to any of the
# dockerfiles
hadolint:
needs: dockerfile-changes
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
dockerfile: ${{ fromJSON(needs.dockerfile-changes.outputs.packages) }}
steps:
- uses: actions/checkout@v3
- uses: hadolint/hadolint-action@v2.1.0
with:
dockerfile: ${{ matrix.dockerfile }}
# Determine if there are python changes
python-changes:
runs-on: ubuntu-latest
outputs:
# Check if the changed status of py is true
2022-04-06 19:27:36 +00:00
updates: steps.filter.outputs.py == 'true'
steps:
# Use paths-filter to determine which paths have changes
# https://github.com/dorny/paths-filter
- uses: dorny/paths-filter@v2
2022-04-06 19:27:36 +00:00
id: filter
with:
filters: |
py: "**.py"
# Run the hadolint dockefile lint if there are changes to any of the
# dockerfiles
python-lint:
needs: python-changes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run Black python linter
if: ${{ needs.python-changes.outputs.updates }}
2022-04-07 20:44:57 +00:00
uses: SkynetLabs/.github/.github/actions/python-black-lint@master
- name: Run Flake8 python linter
if: ${{ needs.python-changes.outputs.updates }}
2022-04-07 20:44:57 +00:00
uses: SkynetLabs/.github/.github/actions/python-flake8-lint@master
# Check if there were any changes since the last tag if this is not a push
# event
changes:
needs: [prettier, eslint, hadolint, python-lint]
runs-on: ubuntu-latest
outputs:
updates: ${{steps.changes.outputs.any == 'true'}}
if: ${{ github.event_name != 'push' }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Required due to the weg Git works, without it this action won't be able to find any or the correct tags
- uses: SkynetLabs/.github/.github/actions/changes-since-last-tag@master
# Make a release if
# - there were changes and this is a scheduled job
# - This is a manually trigger job, i.e. workflow_dispatch
release:
needs: changes
runs-on: ubuntu-latest
if: ${{ (needs.changes.outputs.updates == 'true' && github.event_name == 'schedule') || github.event_name == 'workflow_dispatch' }}
steps:
- uses: actions/checkout@v3
- name: Version Release
uses: SkynetLabs/.github/.github/actions/version-release@master
with:
github-token: ${{secrets.GITHUB_TOKEN}}