From add8f9d1e28d4fbce59b78a8551b33446e722a45 Mon Sep 17 00:00:00 2001 From: Alexis Saettler Date: Mon, 30 Oct 2023 13:49:05 +0100 Subject: [PATCH] ci: fix docker labels (#6978) --- .github/workflows/docker.yml | 15 ++++++++++++--- .github/workflows/push.yml | 1 - .github/workflows/release.yml | 9 +++++---- .github/workflows/tests.yml | 12 +----------- scripts/ci/labels.sh | 15 +++++++++++++++ 5 files changed, 33 insertions(+), 19 deletions(-) create mode 100755 scripts/ci/labels.sh diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 7aff7f0e734..9fd03e16047 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -4,7 +4,6 @@ on: push: branches: - main - - chandler workflow_dispatch: @@ -31,10 +30,15 @@ jobs: - name: Docker meta id: docker_meta - uses: crazy-max/ghaction-docker-meta@v5 + uses: docker/metadata-action@v5 with: images: ghcr.io/${{ github.repository_owner }}/${{ env.package-name }} - tag-sha: true + tags: | + type=sha + labels: | + org.opencontainers.image.description="This is MonicaHQ, your personal memory! MonicaHQ is like a CRM but for the friends, family, and acquaintances around you." + org.opencontainers.image.title="MonicaHQ, the Personal Relationship Manager" + org.opencontainers.image.vendor="Monica" - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -50,6 +54,10 @@ jobs: - name: Configure variables run: scripts/docker/build.sh --skip-build $GITHUB_SHA + - name: Fix labels + id: labels + run: scripts/ci/labels.sh labels "${{ steps.docker_meta.outputs.labels }}" + # Build docker - name: Docker build id: docker_build @@ -62,6 +70,7 @@ jobs: file: scripts/docker/Dockerfile context: . platforms: linux/amd64,linux/arm64 + outputs: ${{ steps.labels.outputs.labels }} - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index e8ee0147161..a404ea40178 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -4,7 +4,6 @@ on: push: branches: - main - - chandler jobs: build: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0185594ee0b..5dbece4fb1f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -94,17 +94,17 @@ jobs: uses: actions/cache@v3 with: path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} + key: ${{ runner.os }}-composer-${{ env.php-version }}-${{ hashFiles('**/composer.lock') }} restore-keys: | - ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} - ${{ runner.os }}-composer-${{ matrix.php-version }} + ${{ runner.os }}-composer-${{ env.php-version }}-${{ hashFiles('**/composer.lock') }} + ${{ runner.os }}-composer-${{ env.php-version }} ${{ runner.os }}-composer- # Yarn - name: Setup Node.js uses: actions/setup-node@v3 with: - node-version: ${{ env.node-version }} + node-version: ${{ env.build-node-version }} - name: Cache yarn files uses: actions/cache@v3 with: @@ -159,4 +159,5 @@ jobs: with: workflow: Release update repo: monicahq/docker + ref: refs/heads/main token: ${{ secrets.DOCKER_GITHUB_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5770b5d6963..fd59ac558bf 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,7 +4,6 @@ on: push: branches: - main - - chandler pull_request: types: [opened, synchronize, reopened] release: @@ -181,15 +180,6 @@ jobs: SONAR_COVERAGE=$(ls -m --format=comma results/${{ env.coverage-with }}/coverage/coverage*.xml | sed -e ':a;N;$!ba;s/\n//g; s/ //g;') echo "list=$SONAR_COVERAGE" >> $GITHUB_OUTPUT - - name: Set project key - id: projectkey - run: | - if [[ "${{ github.repository }}" == "monicahq/chandler" ]]; then - echo "value=monicahq_chandler" >> $GITHUB_OUTPUT - elif [[ "${{ github.repository }}" == "monicahq/monica" ]]; then - echo "value=monica" >> $GITHUB_OUTPUT - fi - - name: SonarCloud Scan if: env.SONAR_TOKEN != '' uses: SonarSource/sonarcloud-github-action@v2.0.2 @@ -198,7 +188,7 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} with: args: | - -Dsonar.projectKey=${{ steps.projectkey.outputs.value }} + -Dsonar.projectKey=monica -Dsonar.organization=monicahq -Dsonar.sources=app,bootstrap,config,database,public,resources,routes -Dsonar.exclusions=bootstrap/cache/*,public/vendor/**,resources/lang/** diff --git a/scripts/ci/labels.sh b/scripts/ci/labels.sh new file mode 100755 index 00000000000..e7887706e7b --- /dev/null +++ b/scripts/ci/labels.sh @@ -0,0 +1,15 @@ +#!/bin/sh +set -ex + +IFS=' +' +variable=$1 +labels=$2 + +{ + echo "$variable<> "$GITHUB_OUTPUT"