Merge pull request #27 from kireque/renovate/minio-1.x #2
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: "Terraform: Build OCI artifacts" | |
on: # yamllint disable-line rule:truthy | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths: | |
- "infrastructure/terraform/**" | |
jobs: | |
changed-files: | |
name: Generate matrix for building images | |
runs-on: ubuntu-22.04 | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Homebrew | |
uses: Homebrew/actions/setup-homebrew@master | |
- name: Setup Tools | |
run: | | |
brew install jo | |
- name: Get changed files | |
id: changed-files | |
uses: tj-actions/changed-files@v38.1.3 | |
with: | |
dir_names: true | |
dir_names_max_depth: 3 | |
json: true | |
files: | | |
infrastructure/terraform/** | |
- name: List all changed files | |
run: | | |
echo '${{ steps.changed-files.outputs.all_changed_files }}' | |
- name: Store changed projects | |
id: set-matrix | |
run: | | |
if [[ "${{ steps.changed-files.outputs.all_changed_files }}" == "[]" ]]; then | |
echo "matrix={\"project\":$(find infrastructure/terraform -type d -mindepth 1 -maxdepth 1 | jo -a)}" >> "${GITHUB_OUTPUT}" | |
else | |
echo "matrix={\"project\":${{ steps.changed-files.outputs.all_changed_files }}}" >> "${GITHUB_OUTPUT}" | |
fi | |
publish: | |
runs-on: ubuntu-22.04 | |
needs: | |
- changed-files | |
strategy: | |
matrix: ${{ fromJSON(needs.changed-files.outputs.matrix) }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Homebrew | |
uses: Homebrew/actions/setup-homebrew@master | |
- name: Setup Tools | |
run: | | |
brew install fluxcd/tap/flux | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish OCI | |
run: | | |
flux push artifact "oci://ghcr.io/kireque/terraform/$(basename ${{ matrix.project }}):$(git rev-parse --short HEAD)" \ | |
--path="./${{ matrix.project }}" \ | |
--source="$(git config --get remote.origin.url)" \ | |
--revision="$(git branch --show-current)/$(git rev-parse HEAD)" | |
- name: Tag OCI | |
run: | | |
flux tag artifact "oci://ghcr.io/kireque/terraform/$(basename ${{ matrix.project }}):$(git rev-parse --short HEAD)" \ | |
--tag main |