Selector/.github/workflows/ci.yml

129 lines
3.4 KiB
YAML
Raw Normal View History

name: ci
2021-09-24 23:35:26 +01:00
on: [push]
jobs:
build:
runs-on: ubuntu-latest
2024-07-01 22:01:03 +01:00
name: Build & Unit Test
2021-09-24 23:35:26 +01:00
strategy:
fail-fast: false
2021-09-24 23:35:26 +01:00
matrix:
2023-11-16 17:49:24 +00:00
dotnet-version: [ '8.0.x' ]
2021-09-24 23:35:26 +01:00
steps:
2024-07-19 18:31:27 +01:00
- uses: actions/checkout@v4
2021-09-24 23:35:26 +01:00
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
2022-11-09 22:45:00 +00:00
uses: actions/setup-dotnet@v3.0.3
2021-09-24 23:35:26 +01:00
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Install Dependencies
2023-01-21 17:10:00 +00:00
run: dotnet restore Selector.Core.sln
2021-09-24 23:35:26 +01:00
- name: Build
run: dotnet build --configuration Debug --no-restore Selector.Core.sln
2021-09-24 23:35:26 +01:00
- name: Test
2023-01-21 17:10:00 +00:00
run: dotnet test --no-restore --verbosity normal Selector.Core.sln
2023-01-27 23:22:29 +00:00
build-MAUI:
runs-on: windows-latest
2024-07-01 22:01:03 +01:00
name: Build MAUI
2023-01-27 23:22:29 +00:00
needs: [build] # for ignoring bad builds
strategy:
fail-fast: false
matrix:
2023-11-16 17:49:24 +00:00
dotnet-version: [ '8.0.x' ]
2023-01-27 23:22:29 +00:00
steps:
2024-07-19 18:31:27 +01:00
- uses: actions/checkout@v4
2023-01-27 23:22:29 +00:00
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3.0.3
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Build
2023-01-27 23:30:55 +00:00
run: dotnet build --configuration Debug Selector.MAUI\Selector.MAUI.csproj
2023-01-27 23:22:29 +00:00
2022-02-13 12:14:35 +00:00
build-Docker:
runs-on: ubuntu-latest
2024-07-01 22:01:03 +01:00
name: Build Containers
needs: [build, build-Js] # for ignoring bad builds
2023-09-19 18:14:58 +01:00
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))
2022-02-13 12:14:35 +00:00
steps:
2022-02-13 12:19:21 +00:00
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
2022-02-13 12:14:35 +00:00
- name: Build CLI Container
2024-07-19 18:31:27 +01:00
uses: docker/build-push-action@v6
2022-02-13 12:14:35 +00:00
with:
push: true
2023-09-19 18:14:58 +01:00
tags: |
sarsoo/selector-cli:latest
sarsoo/selector-cli:${{ github.ref_name }}
2022-02-13 12:19:21 +00:00
file: Dockerfile.CLI
2022-02-13 12:14:35 +00:00
- name: Build Web Container
2024-07-19 18:31:27 +01:00
uses: docker/build-push-action@v6
2022-02-13 12:14:35 +00:00
with:
push: true
2023-09-19 18:14:58 +01:00
tags: |
sarsoo/selector-web:latest
sarsoo/selector-web:${{ github.ref_name }}
2022-02-13 12:19:21 +00:00
file: Dockerfile.Web
2022-02-13 12:14:35 +00:00
2024-07-01 22:01:03 +01:00
deploy:
runs-on: ubuntu-latest
name: Deploy
needs: [build-Docker] # for ignoring bad builds
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))
environment:
name: prod
url: https://selector.sarsoo.xyz
steps:
2024-07-19 18:31:27 +01:00
- uses: actions/checkout@v4
2024-07-01 22:01:03 +01:00
- name: Tailscale
uses: tailscale/github-action@v2
with:
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
tags: tag:ci
2024-07-01 22:37:30 +01:00
version: 1.68.1
2024-07-01 22:01:03 +01:00
- name: Deploy
2024-07-07 22:41:00 +01:00
run: ssh -o StrictHostKeyChecking=no ${{ secrets.TS_SSH }} -t "cd selector/ && docker compose up -d --pull always"
2024-07-01 22:01:03 +01:00
2021-10-23 11:11:03 +01:00
build-Js:
2021-10-23 11:11:03 +01:00
runs-on: ubuntu-latest
2024-07-01 22:01:03 +01:00
name: Build Frontend
2021-10-23 11:11:03 +01:00
strategy:
fail-fast: false
matrix:
2023-11-16 17:49:24 +00:00
node: [21]
2021-10-23 11:11:03 +01:00
steps:
2024-07-19 18:31:27 +01:00
- uses: actions/checkout@v4
2021-10-23 11:11:03 +01:00
- name: Install Node ${{ matrix.node }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
2021-10-23 11:11:03 +01:00
- name: Install Node Packages
working-directory: ./Selector.Web
run: npm ci
2021-10-23 11:11:03 +01:00
- name: Compile Front-end
working-directory: ./Selector.Web
run: npm run build --if-present