|
| 1 | +name: CI/CD |
| 2 | + |
| 3 | +on: [push, workflow_dispatch] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + strategy: |
| 9 | + matrix: |
| 10 | + version: [10, 12, 14] |
| 11 | + type: ['', '-qa'] |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout code |
| 15 | + uses: actions/checkout@v2 |
| 16 | + |
| 17 | + - name: Set up Docker Buildx |
| 18 | + uses: docker/setup-buildx-action@v1 |
| 19 | + |
| 20 | + - name: Cache Docker layers |
| 21 | + uses: actions/cache@v2 |
| 22 | + with: |
| 23 | + path: /tmp/.buildx-cache |
| 24 | + key: docker-buildx-${{ matrix.version }}${{ matrix.type }}-${{ github.sha }} |
| 25 | + restore-keys: docker-buildx-${{ matrix.version }}${{ matrix.type }}- |
| 26 | + |
| 27 | + - name: Build |
| 28 | + run: | |
| 29 | + docker buildx build \ |
| 30 | + --cache-from type=local,src=/tmp/.buildx-cache/${{ matrix.version }}${{ matrix.type }} \ |
| 31 | + --cache-to type=local,dest=/tmp/.buildx-cache/${{ matrix.version }}${{ matrix.type }} \ |
| 32 | + --output type=docker \ |
| 33 | + --tag kooldev/node:${{ matrix.version }}${{ matrix.type }} \ |
| 34 | + ${{ matrix.version }}${{ matrix.type }} |
| 35 | +
|
| 36 | + - name: Build (adonis) |
| 37 | + run: | |
| 38 | + docker buildx build \ |
| 39 | + --cache-from type=local,src=/tmp/.buildx-cache/${{ matrix.version }}-adonis${{ matrix.type }} \ |
| 40 | + --cache-to type=local,dest=/tmp/.buildx-cache/${{ matrix.version }}-adonis${{ matrix.type }} \ |
| 41 | + --output type=docker \ |
| 42 | + --tag kooldev/node:${{ matrix.version }}-adonis${{ matrix.type }} \ |
| 43 | + ${{ matrix.version }}-adonis${{ matrix.type }} |
| 44 | +
|
| 45 | + - name: Build (nest) |
| 46 | + run: | |
| 47 | + docker buildx build \ |
| 48 | + --cache-from type=local,src=/tmp/.buildx-cache/${{ matrix.version }}-nest${{ matrix.type }} \ |
| 49 | + --cache-to type=local,dest=/tmp/.buildx-cache/${{ matrix.version }}-nest${{ matrix.type }} \ |
| 50 | + --output type=docker \ |
| 51 | + --tag kooldev/node:${{ matrix.version }}-nest${{ matrix.type }} \ |
| 52 | + ${{ matrix.version }}-nest${{ matrix.type }} |
| 53 | +
|
| 54 | + - name: Tests |
| 55 | + run: | |
| 56 | + for suffix in '' -adonis -nest; do |
| 57 | + docker run kooldev/node:${{ matrix.version }}$suffix${{ matrix.type }} node -v; |
| 58 | + docker run kooldev/node:${{ matrix.version }}$suffix${{ matrix.type }} npm -v; |
| 59 | + docker run kooldev/node:${{ matrix.version }}$suffix${{ matrix.type }} yarn -v; |
| 60 | +
|
| 61 | + docker run -e ASUSER=1000 kooldev/node:${{ matrix.version }}$suffix${{ matrix.type }} node -v; |
| 62 | + docker run -e ASUSER=1000 kooldev/node:${{ matrix.version }}$suffix${{ matrix.type }} npm -v; |
| 63 | + docker run -e ASUSER=1000 kooldev/node:${{ matrix.version }}$suffix${{ matrix.type }} yarn -v; |
| 64 | + done |
| 65 | +
|
| 66 | + - name: Login to DockerHub |
| 67 | + uses: docker/login-action@v1 |
| 68 | + if: github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-node' |
| 69 | + with: |
| 70 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 71 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 72 | + |
| 73 | + - name: Push to DockerHub |
| 74 | + if: github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-node' |
| 75 | + run: | |
| 76 | + docker push kooldev/node:${{ matrix.version }}${{ matrix.type }} |
| 77 | + docker push kooldev/node:${{ matrix.version }}-adonis${{ matrix.type }} |
| 78 | + docker push kooldev/node:${{ matrix.version }}-nest${{ matrix.type }} |
0 commit comments