Files
redmine-mcp/.github/workflows/build.yml
T

81 lines
2.3 KiB
YAML

name: Build and push image
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
outputs:
image_tag: ${{ steps.tag.outputs.value }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set image tag
id: tag
run: echo "value=sha-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: container/Containerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/${{ github.repository }}:${{ steps.tag.outputs.value }}
cache-from: type=gha
cache-to: type=gha,mode=max
update-chart:
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Bump chart version and set appVersion
id: chart
run: |
CURRENT=$(grep '^version:' helm/Chart.yaml | awk '{print $2}')
MAJOR=$(echo $CURRENT | cut -d. -f1)
MINOR=$(echo $CURRENT | cut -d. -f2)
PATCH=$(echo $CURRENT | cut -d. -f3)
NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
sed -i "s/^version: .*/version: $NEW_VERSION/" helm/Chart.yaml
sed -i "s/^appVersion: .*/appVersion: \"${{ needs.build.outputs.image_tag }}\"/" helm/Chart.yaml
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Commit and push chart update
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add helm/Chart.yaml
git commit -m "chore: chart ${{ steps.chart.outputs.version }}, appVersion ${{ needs.build.outputs.image_tag }} [skip ci]"
git push