|
| 1 | +# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node |
| 2 | +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions |
| 3 | + |
| 4 | +name: build CoderBot frontend |
| 5 | + |
| 6 | +on: push |
| 7 | + |
| 8 | +jobs: |
| 9 | + build-frontend: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + node-version: [16.x] |
| 15 | + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ |
| 16 | + |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v3 |
| 19 | + - name: Use Node.js ${{ matrix.node-version }} |
| 20 | + uses: actions/setup-node@v3 |
| 21 | + with: |
| 22 | + node-version: ${{ matrix.node-version }} |
| 23 | + cache: 'npm' |
| 24 | + - run: npm ci |
| 25 | + - run: npm run build --if-present |
| 26 | + - name: Archive dist |
| 27 | + uses: actions/upload-artifact@v3 |
| 28 | + with: |
| 29 | + name: dist |
| 30 | + path: dist |
| 31 | + |
| 32 | + release-frontend: |
| 33 | + runs-on: ubuntu-latest |
| 34 | + needs: build-frontend |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v3 # Checking out the repo |
| 37 | + - name: Docker meta |
| 38 | + id: meta |
| 39 | + uses: docker/metadata-action@v4 |
| 40 | + with: |
| 41 | + # list of Docker images to use as base name for tags |
| 42 | + images: ghcr.io/coderbotorg/frontend |
| 43 | + # generate Docker tags based on the following events/attributes |
| 44 | + tags: | |
| 45 | + # always latest |
| 46 | + type=raw,value=latest |
| 47 | + # branch event |
| 48 | + type=ref,event=branch |
| 49 | + # tag event |
| 50 | + type=ref,event=tag |
| 51 | + # pull request event |
| 52 | + type=ref,event=pr |
| 53 | + # push event |
| 54 | + type=sha,enable=true,prefix=git-,format=short |
| 55 | + - name: Download dist artifact |
| 56 | + uses: actions/download-artifact@v3 |
| 57 | + with: |
| 58 | + name: dist |
| 59 | + path: dist |
| 60 | + - run: wget https://github.com/CoderBotOrg/docs/releases/download/v0.1/docs.tgz |
| 61 | + - run: mkdir -p cb_docs |
| 62 | + - run: tar xzf docs.tgz -C cb_docs |
| 63 | + - run: rm docs.tgz |
| 64 | + - name: Set up QEMU |
| 65 | + uses: docker/setup-qemu-action@v2 |
| 66 | + - name: Set up Docker Buildx |
| 67 | + id: buildx |
| 68 | + uses: docker/setup-buildx-action@v2 |
| 69 | + - name: Login to DockerHub |
| 70 | + uses: docker/login-action@v2 |
| 71 | + with: |
| 72 | + registry: ghcr.io |
| 73 | + username: ${{ github.actor }} |
| 74 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 75 | + - name: Build and push |
| 76 | + uses: docker/build-push-action@v3 |
| 77 | + with: |
| 78 | + push: true |
| 79 | + platforms: linux/arm/v7 |
| 80 | + tags: ${{ steps.meta.outputs.tags }} |
| 81 | + context: . |
| 82 | + file: docker/Dockerfile |
| 83 | + cache-from: type=registry,ref=ghcr.io/coderbotorg/frontend:latest |
| 84 | + cache-to: type=inline |
0 commit comments