diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..b27a96d --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,62 @@ +name: 'API Build' +on: + workflow_call: + inputs: + environment_name: + required: true + type: string + version_number: + required: true + type: string + +jobs: + build: + runs-on: ubuntu-latest + environment: ${{ inputs.environment_name }} + steps: + - name: Checkout + uses: actions/checkout@v5 + with: + sparse-checkout: | + api + + - name: Install Nest CLI + run: | + npm install -g @nestjs/cli + + - name: 'Setup Node' + uses: actions/setup-node@v4 + with: + node-version: ${{ vars.NODE_VERSION }} + + - name: Install dependencies + run: | + npm ci + + - name: Build API + run: | + npm run build -w api + + - name: Build Client + run: | + npm run build -w client + + - name: Log into Docker Hub + if: ${{ github.event_name != 'pull_request' }} + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Setup Docker Buildx + if: ${{ github.event_name != 'pull_request' }} + uses: docker/setup-buildx-action@v3 + + - name: Build and push to registry + if: ${{ github.event_name != 'pull_request' }} + uses: docker/build-push-action@v6 + with: + push: true + tags: noahspan/flying:${{ inputs.version_number }} + context: . + target: api diff --git a/.github/workflows/changes.yaml b/.github/workflows/changes.yaml index 917786e..1d864c4 100644 --- a/.github/workflows/changes.yaml +++ b/.github/workflows/changes.yaml @@ -4,8 +4,8 @@ on: outputs: api: value: ${{ jobs.changes.outputs.api }} - app: - value: ${{ jobs.changes.outputs.app }} + client: + value: ${{ jobs.changes.outputs.client }} jobs: changes: @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest outputs: api: ${{ steps.filter.outputs.api }} - app: ${{ steps.filter.outputs.app }} + client: ${{ steps.filter.outputs.client }} steps: - uses: actions/checkout@v3 @@ -24,5 +24,5 @@ jobs: filters: | api: - 'api/**' - app: - - 'app/**' \ No newline at end of file + client: + - 'client/**' \ No newline at end of file diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 0fd1067..7a6378b 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -9,7 +9,7 @@ jobs: uses: ./.github/workflows/changes.yaml build: - if: ${{ needs.changes.outputs.app == 'true' }} + if: ${{ needs.changes.outputs.app == 'true' || needs.changes.outputs.client == 'true' }} name: build needs: - changes diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 3de7e68..6a219ed 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -7,23 +7,12 @@ jobs: changes: uses: ./.github/workflows/changes.yaml - build-api: - if: ${{ needs.changes.outputs.api == 'true' }} - name: build-api + build: + if: ${{ needs.changes.outputs.app == 'true' || needs.changes.outputs.client == 'true'}} + name: build needs: - changes - uses: ./.github/workflows/api_build.yaml - with: - environment_name: pull_request - version_number: ${{ github.run_id }} - secrets: inherit - - build-app: - if: ${{ needs.changes.outputs.app == 'true' }} - name: build-app - needs: - - changes - uses: ./.github/workflows/app_build.yaml + uses: ./.github/workflows/build.yaml with: environment_name: pull_request version_number: ${{ github.run_id }} diff --git a/database/litestream/litestream.yml b/database/litestream/litestream.yml new file mode 100644 index 0000000..21c6706 --- /dev/null +++ b/database/litestream/litestream.yml @@ -0,0 +1,4 @@ +dbs: + - path: /var/lib/data/flying.db + replicas: + - path: /mnt/backup/flying.db \ No newline at end of file