chore(release): 1.0.8 #89
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker – Build and Push | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- '*' | |
pull_request: | |
paths: | |
- 'services/**' | |
branches: | |
- 'master' | |
jobs: | |
analyse-changed-packages: | |
runs-on: ubuntu-latest | |
outputs: | |
changed: ${{ steps.changed-packages.outputs.CHANGED }} | |
changedPackages: ${{ steps.changed-packages.outputs.CHANGED_PACKAGES }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
run_install: false | |
- run: | | |
SINCE=$(git rev-list --tags --max-count=1) | |
echo SINCE=$SINCE >> $GITHUB_OUTPUT | |
echo SINCE=$SINCE | |
id: since | |
- run: | | |
pnpm list -r --json --filter "...[$SINCE]" | jq '[.[] | select(.private == false) | {name, path}]' > ./tmp.json | |
CHANGED_PACKAGES=$(jq '[.[] | .name]' ./tmp.json) | |
echo CHANGED_PACKAGES=$CHANGED_PACKAGES >> $GITHUB_OUTPUT | |
echo CHANGED_PACKAGES=$CHANGED_PACKAGES | |
id: changed-packages | |
env: | |
SINCE: ${{ steps.since.outputs.SINCE }} | |
build-and-push: | |
runs-on: ubuntu-latest | |
environment: docker | |
needs: [analyse-changed-packages] | |
if: ${{ needs.analyse-changed-packages.outputs.changedPackages != '[]'}} | |
strategy: | |
fail-fast: false | |
matrix: | |
package: ${{fromJson(needs.analyse-changed-packages.outputs.changedPackages)}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
run_install: false | |
- run: echo "package=${{ matrix.package }}" | |
- name: get directory for package | |
id: get-directory | |
run: | | |
directory=$(pnpm ls -r --json --filter $MATRIX_PACKAGE | jq -r '.[0] | .path') | |
directory="${directory##*/democracy-development/}" | |
# Ausgabe | |
echo "directory=$directory" >> $GITHUB_OUTPUT | |
env: | |
MATRIX_PACKAGE: ${{ matrix.package }} | |
- run: echo "directory=${{ steps.get-directory.outputs.directory }}" | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: democracy/${{ matrix.package }} | |
tags: | | |
type=ref,event=branch,enable=${{ github.ref == format('refs/heads/{0}', 'master') || github.ref == format('refs/heads/{0}', 'alpha') || github.ref == format('refs/heads/{0}', 'internal') }} | |
type=ref,event=pr | |
type=match,asref=foo,pattern=${{ matrix.package }}@v(\d+.\d+.\d+)(-alpha.\d+)?,group=1 | |
type=semver,pattern={{version}},use=foo | |
type=sha,enable=${{ github.event_name == 'workflow_dispatch' }} | |
- name: Print Meta Summary | |
run: | | |
echo "🏷️ Tags: ${{ steps.meta.outputs.tags }} | |
" >> $GITHUB_STEP_SUMMARY | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
install: true | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-multi-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-multi-buildx | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Read .node-version | |
id: node_version | |
run: echo "version=$(cat .node-version | tr -d 'v')" >> $GITHUB_OUTPUT | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: infra/Dockerfile.service | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
target: runner | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new | |
build-args: | | |
SERVICE=${{ matrix.package }} | |
SERVICE_PATH=${{ steps.get-directory.outputs.directory }} | |
NODE_VERSION=${{ steps.node_version.outputs.version }} | |
- name: Move buildx cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} |