RocketChat/Rocket.Chat

View on GitHub
.github/actions/build-docker/action.yml

Summary

Maintainability
Test Coverage
name: 'Meteor Docker'

inputs:
  CR_USER:
    required: true
  CR_PAT:
    required: true
  node-version:
    required: true
    description: 'Node version'
    type: string
  platform:
    required: false
    description: 'Platform'
    type: string

runs:
  using: composite

  steps:
    - name: Login to GitHub Container Registry
      if: (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'release' || github.ref == 'refs/heads/develop')
      uses: docker/login-action@v2
      with:
        registry: ghcr.io
        username: ${{ inputs.CR_USER }}
        password: ${{ inputs.CR_PAT }}

    - name: Restore build
      uses: actions/download-artifact@v3
      with:
        name: build
        path: /tmp/build

    - name: Unpack build
      shell: bash
      run: |
        cd /tmp/build
        tar xzf Rocket.Chat.tar.gz
        rm Rocket.Chat.tar.gz

    - uses: dtinth/setup-github-actions-caching-for-turbo@v1

    - name: Setup NodeJS
      uses: ./.github/actions/setup-node
      with:
        node-version: ${{ inputs.node-version }}
        cache-modules: true
        install: true

    - run: yarn build
      shell: bash

    - name: Build Docker images
      shell: bash
      run: |
        args=(rocketchat)

        if [[ '${{ inputs.platform }}' = 'alpine' ]]; then
          args+=($SERVICES_PUBLISH)
        fi;

        docker compose -f docker-compose-ci.yml build "${args[@]}"

    - name: Publish Docker images to GitHub Container Registry
      if: (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'release' || github.ref == 'refs/heads/develop')
      shell: bash
      run: |
        args=(rocketchat)

        if [[ '${{ inputs.platform }}' = 'alpine' ]]; then
          args+=($SERVICES_PUBLISH)
        fi;

        docker compose -f docker-compose-ci.yml push "${args[@]}"