Merge pull request #98 from bananu7/limit-harvesting-to-one #203
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
name: Node.js Client + Server build | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'yarn' | |
- run: yarn install --frozen-lockfile | |
- name: Set outputs | |
id: vars | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Build client | |
working-directory: ./packages/client | |
run: yarn build | |
- name: Build server | |
working-directory: ./packages/server | |
run: yarn build | |
- name: Run server tests | |
working-directory: ./packages/server | |
run: yarn test | |
- name: Do a server dry run | |
working-directory: ./packages/server | |
run: yarn dev --dry | |
- name: Upload server artifact | |
if: github.ref == 'refs/heads/main' | |
uses: actions/upload-artifact@v3.1.0 | |
with: | |
name: server-${{ steps.vars.outputs.sha_short }} | |
path: ./packages/server/dist/ | |
- name: Upload client artifact | |
if: github.ref == 'refs/heads/main' | |
uses: actions/upload-artifact@v3.1.0 | |
with: | |
name: client-${{ steps.vars.outputs.sha_short }} | |
path: ./packages/client/dist/ | |
docker-server: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Set version string | |
id: vars | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Store version to a file | |
run: echo "${{ steps.vars.outputs.sha_short }}" > ./packages/server/version.txt | |
- | |
name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- | |
name: Build and push server container - PR to main | |
if: ${{ github.event_name == 'pull_request' }} | |
uses: docker/build-push-action@v3 | |
with: | |
context: ./ | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/rts:server-pr-${{ steps.vars.outputs.sha_short }} | |
- | |
name: Build and push server container - main branch | |
if: ${{ github.ref == 'refs/heads/main' }} | |
uses: docker/build-push-action@v3 | |
with: | |
context: ./ | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/rts:server, ${{ secrets.DOCKERHUB_USERNAME }}/rts:server-${{ steps.vars.outputs.sha_short }} | |