Merge pull request #31 from ctrsploit/containerd/v2.2.1 #41
This file contains hidden or 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: make | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| base_sha: | |
| description: "Base commit SHA for VERSION diff" | |
| required: false | |
| type: string | |
| head_sha: | |
| description: "Head commit SHA for VERSION diff (default: current SHA)" | |
| required: false | |
| type: string | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "**/.env" | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| detect-version-change: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| changed: ${{ steps.collect.outputs.changed }} | |
| matrix: ${{ steps.collect.outputs.matrix }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Collect .env paths with VERSION changes | |
| id: collect | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| if [[ "${{ github.event_name }}" == "push" ]]; then | |
| BASE_SHA="${{ github.event.before }}" | |
| HEAD_SHA="${{ github.sha }}" | |
| else | |
| BASE_SHA="${{ github.event.inputs.base_sha }}" | |
| HEAD_SHA="${{ github.event.inputs.head_sha }}" | |
| HEAD_SHA="${HEAD_SHA:-${{ github.sha }}}" | |
| if [[ -z "${BASE_SHA}" ]]; then | |
| echo "workflow_dispatch without base_sha: skipping make job" | |
| echo "changed=false" >> "${GITHUB_OUTPUT}" | |
| echo 'matrix=[]' >> "${GITHUB_OUTPUT}" | |
| exit 0 | |
| fi | |
| fi | |
| if [[ "${BASE_SHA}" == "0000000000000000000000000000000000000000" ]]; then | |
| BASE_SHA="$(git rev-list --max-parents=0 "${HEAD_SHA}" | tail -n 1)" | |
| fi | |
| git rev-parse --verify "${BASE_SHA}^{commit}" >/dev/null | |
| git rev-parse --verify "${HEAD_SHA}^{commit}" >/dev/null | |
| mapfile -t ENV_FILES < <(git diff --name-only --diff-filter=AMR -G '^VERSION=' "${BASE_SHA}" "${HEAD_SHA}" -- '**/.env') | |
| declare -A ENV_DIRS=() | |
| for file in "${ENV_FILES[@]}"; do | |
| ENV_DIRS["$(dirname "${file}")"]=1 | |
| done | |
| if [[ ${#ENV_DIRS[@]} -eq 0 ]]; then | |
| echo "changed=false" >> "${GITHUB_OUTPUT}" | |
| echo 'matrix=[]' >> "${GITHUB_OUTPUT}" | |
| exit 0 | |
| fi | |
| MATRIX_JSON="$(printf '%s\n' "${!ENV_DIRS[@]}" | sort | jq -R . | jq -cs .)" | |
| echo "changed=true" >> "${GITHUB_OUTPUT}" | |
| echo "matrix=${MATRIX_JSON}" >> "${GITHUB_OUTPUT}" | |
| make-all: | |
| runs-on: ubuntu-latest | |
| needs: detect-version-change | |
| if: needs.detect-version-change.outputs.changed == 'true' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| env_path: ${{ fromJson(needs.detect-version-change.outputs.matrix) }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Run CI make targets | |
| run: make ci ENV="${{ matrix.env_path }}" |