|
| 1 | +# 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 |
| 2 | +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions |
| 3 | + |
| 4 | +name: Docker |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: [ master ] |
| 9 | + pull_request: |
| 10 | + branches: [ master ] |
| 11 | +env: |
| 12 | + REGISTRY: ghcr.io |
| 13 | + IMAGE_NAME: ${{ github.repository }} |
| 14 | + |
| 15 | + |
| 16 | +jobs: |
| 17 | + test: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + strategy: |
| 21 | + matrix: |
| 22 | + node-version: [16.x, 18.x] |
| 23 | + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ |
| 24 | + |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v3 |
| 27 | + - name: Use Node.js ${{ matrix.node-version }} |
| 28 | + uses: actions/setup-node@v3 |
| 29 | + with: |
| 30 | + node-version: ${{ matrix.node-version }} |
| 31 | + cache: 'npm' |
| 32 | + - run: npm ci |
| 33 | + # - run: npm run build --if-present |
| 34 | + - run: npm test |
| 35 | + eslint: |
| 36 | + runs-on: ubuntu-latest |
| 37 | + |
| 38 | + strategy: |
| 39 | + matrix: |
| 40 | + node-version: [16.x, 18.x] |
| 41 | + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ |
| 42 | + |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v3 |
| 45 | + - name: Use Node.js ${{ matrix.node-version }} |
| 46 | + uses: actions/setup-node@v3 |
| 47 | + with: |
| 48 | + node-version: ${{ matrix.node-version }} |
| 49 | + cache: 'npm' |
| 50 | + - run: npm ci |
| 51 | + # - run: npm run build --if-present |
| 52 | + - run: npm run eslint |
| 53 | + build: |
| 54 | + needs: |
| 55 | + - test |
| 56 | + - eslint |
| 57 | + |
| 58 | + runs-on: ubuntu-latest |
| 59 | + permissions: |
| 60 | + contents: read |
| 61 | + packages: write |
| 62 | + |
| 63 | + steps: |
| 64 | + - name: Checkout repository |
| 65 | + uses: actions/checkout@v3 |
| 66 | + # Login against a Docker registry except on PR |
| 67 | + # https://github.com/docker/login-action |
| 68 | + - name: Log into registry ${{ env.REGISTRY }} |
| 69 | + uses: docker/login-action@v2 |
| 70 | + with: |
| 71 | + registry: ${{ env.REGISTRY }} |
| 72 | + username: ${{ github.actor }} |
| 73 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + |
| 75 | + # Extract metadata (tags, labels) for Docker |
| 76 | + # https://github.com/docker/metadata-action |
| 77 | + - name: Extract Docker metadata |
| 78 | + id: meta |
| 79 | + uses: docker/metadata-action@v4 |
| 80 | + with: |
| 81 | + tags: | |
| 82 | + type=sha,prefix=sha- |
| 83 | + type=ref,event=branch |
| 84 | + type=raw,value=latest |
| 85 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 86 | + # https://github.com/docker/build-push-action |
| 87 | + - name: Build and push Docker image |
| 88 | + id: build-and-push |
| 89 | + uses: docker/build-push-action@v3 |
| 90 | + with: |
| 91 | + context: . |
| 92 | + push: true |
| 93 | + tags: ${{ steps.meta.outputs.tags }} |
| 94 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments