|
| 1 | +# SPDX-FileCopyrightText: 2022 Alliander N.V. |
| 2 | +# |
| 3 | +# SPDX-License-Identifier: Apache-2.0 |
| 4 | + |
| 5 | +name: Release Project |
| 6 | + |
| 7 | +on: |
| 8 | + release: |
| 9 | + types: [released] |
| 10 | + |
| 11 | +jobs: |
| 12 | + push_to_registry: |
| 13 | + name: Build and publish |
| 14 | + runs-on: ubuntu-latest |
| 15 | + timeout-minutes: 45 |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + |
| 20 | + |
| 21 | + - name: Cache Docker Register |
| 22 | + uses: actions/cache@v3 |
| 23 | + with: |
| 24 | + path: /tmp/.buildx-cache |
| 25 | + key: ${{ runner.os }}-buildx-${{ hashFiles('**/Dockerfile') }} |
| 26 | + |
| 27 | + - name: Extract tag name |
| 28 | + id: extract_tagname |
| 29 | + shell: bash |
| 30 | + # Extra the tagname form the git reference, value of GITHUB_REF will be something like refs/tags/<tag_name>. |
| 31 | + run: echo "##[set-output name=tagname;]$(echo ${GITHUB_REF##*/})" |
| 32 | + - name: Set up Docker Buildx |
| 33 | + id: buildx |
| 34 | + uses: docker/setup-buildx-action@v3 |
| 35 | + - name: Login to Docker Hub |
| 36 | + uses: docker/login-action@v3 |
| 37 | + with: |
| 38 | + username: ${{ secrets.DOCKER_HUB_USERNAME }} |
| 39 | + password: ${{ secrets.DOCKER_HUB_TOKEN }} |
| 40 | + - name: Use Node.js 14.x |
| 41 | + uses: actions/setup-node@v4 |
| 42 | + with: |
| 43 | + node-version: '14.x' |
| 44 | + |
| 45 | + - name: Build application with npm |
| 46 | + run: | |
| 47 | + cd packages/compas-open-scd |
| 48 | + npm ci |
| 49 | + npm run-script build |
| 50 | + - name: Build and push docker image to Docker Hub |
| 51 | + uses: docker/build-push-action@v5 |
| 52 | + with: |
| 53 | + # Set the context to use the packages/compas-open-scd directory and not execute it's own git checkout. |
| 54 | + context: packages/compas-open-scd |
| 55 | + push: true |
| 56 | + # Tag the images using the tagname and also latest. |
| 57 | + tags: | |
| 58 | + lfenergy/compas-open-scd:${{ steps.extract_tagname.outputs.tagname }} |
| 59 | + lfenergy/compas-open-scd:latest |
0 commit comments