mirror of
https://github.com/teslamate-org/teslamate.git
synced 2026-01-24 21:06:08 +08:00
126 lines
4.2 KiB
YAML
126 lines
4.2 KiB
YAML
name: Build GHCR images
|
|
|
|
on:
|
|
pull_request:
|
|
branches: ["main"]
|
|
paths:
|
|
- "**/*"
|
|
- "!.github/**" # Important: Exclude PRs related to .github from auto-run
|
|
- "!.github/workflows/**" # Important: Exclude PRs related to .github/workflows from auto-run
|
|
- "!.github/actions/**" # Important: Exclude PRs related to .github/actions from auto-run
|
|
|
|
env:
|
|
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
jobs:
|
|
check_paths:
|
|
uses: ./.github/workflows/check_paths.yml
|
|
|
|
check_if_pr_from_outside_repo:
|
|
name: Check if PR from outside repo
|
|
# as we currently only push ghcr images for PRs from our own repo
|
|
needs: check_paths
|
|
if: needs.check_paths.outputs.githubfolder != 'true'
|
|
outputs:
|
|
is_pr_from_outside_repo: ${{ steps.check_if_pr_from_outside_repo.outputs.is_pr_from_outside_repo }}
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- name: check if PR from outside repo
|
|
id: check_if_pr_from_outside_repo
|
|
shell: bash
|
|
run: |
|
|
echo "::group::Check if PR from outside repo"
|
|
if [[ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]]; then
|
|
echo "This PR is from outside the repo"
|
|
echo "is_pr_from_outside_repo=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "This PR is from our own repo"
|
|
echo "is_pr_from_outside_repo=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
echo "::endgroup::"
|
|
|
|
teslamate_build:
|
|
name: Build images
|
|
needs:
|
|
- check_paths
|
|
- check_if_pr_from_outside_repo
|
|
if: needs.check_paths.outputs.githubfolder != 'true' && needs.check_if_pr_from_outside_repo.outputs.is_pr_from_outside_repo == 'false'
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- platform: "linux/amd64"
|
|
runs_on: "ubuntu-24.04"
|
|
cache_id: amd64
|
|
- platform: "linux/arm/v7"
|
|
runs_on: "buildjet-2vcpu-ubuntu-2204-arm"
|
|
cache_id: arm
|
|
- platform: "linux/arm64"
|
|
runs_on: "buildjet-2vcpu-ubuntu-2204-arm"
|
|
cache_id: arm64
|
|
|
|
runs-on: ${{ matrix.runs_on }}
|
|
timeout-minutes: 10
|
|
steps:
|
|
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
|
|
|
- name: Buildx
|
|
uses: ./.github/actions/build
|
|
with:
|
|
docker_password: ${{ secrets.DOCKER_PASSWORD }}
|
|
repository_owner: ${{ github.repository_owner }}
|
|
repository: ${{ github.repository }}
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
version: ${{ github.head_ref || github.ref_name }}
|
|
labels: |
|
|
org.opencontainers.image.version=${{ github.ref || github.ref_name }}
|
|
|
|
teslamate_merge:
|
|
name: Merge GHCR images
|
|
needs:
|
|
- check_paths
|
|
- teslamate_build
|
|
if: needs.check_paths.outputs.githubfolder != 'true'
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 10
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Merge
|
|
id: merge
|
|
uses: ./.github/actions/merge
|
|
with:
|
|
image: ${{ env.REGISTRY_IMAGE }}
|
|
|
|
grafana:
|
|
needs:
|
|
- check_paths
|
|
- check_if_pr_from_outside_repo
|
|
if: needs.check_paths.outputs.githubfolder != 'true' && needs.check_if_pr_from_outside_repo.outputs.is_pr_from_outside_repo == 'false'
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
|
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- uses: ./.github/actions/grafana
|
|
with:
|
|
image: ${{ env.REGISTRY_IMAGE }}/grafana
|
|
labels: |
|
|
org.opencontainers.image.version=${{ github.ref || github.ref_name }}
|