Skip to content

Update release.yml

Update release.yml #58

Workflow file for this run

name: CI
permissions:
contents: read
on:
push:
branches: [main]
tags: ["v*.*.*"]
pull_request:
branches: [main]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Building webapp
- uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Check and build frontend
working-directory: ./webapp
run: |
npm ci
npm run check
npm run lint
npm run build
# Building server
- uses: actions/setup-go@v5
with:
go-version: 1.23
- name: "Test backend"
run: go test ./... -v -bench . -coverprofile coverage.out
- name: "Upload coverage report"
uses: actions/upload-artifact@v4
with:
name: go-code-coverage
path: coverage.out
- name: "Build backend"
run: go build -o ./build/simple-server-monitor ./cmd/server
- name: Upload Linux executable
uses: actions/upload-artifact@v4
with:
name: simple-server-monitor
path: build
retention-days: 5
docker:
needs: [ build ]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log in to the Container registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}