Merge pull request #602 from cloud-pi-native/develop #58
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: Create new release PR | |
on: | |
push: | |
branches: | |
- main | |
env: | |
REGISTRY: "ghcr.io" | |
NAMESPACE: "${{ github.repository }}" | |
PLATFORM: "linux/amd64,linux/arm64" | |
jobs: | |
release: | |
name: Create new release | |
runs-on: ubuntu-latest | |
outputs: | |
release-created: ${{ steps.release.outputs.release_created }} | |
major-tag: ${{ steps.release.outputs.major }} | |
minor-tag: ${{ steps.release.outputs.minor }} | |
patch-tag: ${{ steps.release.outputs.patch }} | |
steps: | |
- name: Checks-out repository | |
uses: actions/checkout@v3 | |
- name: Pre release new version | |
uses: google-github-actions/release-please-action@v3 | |
id: release | |
with: | |
package-name: console | |
release-type: node | |
default-branch: main | |
group-pull-request-title-pattern: release v${version} | |
extra-files: | | |
helm/Chart.yaml | |
helm/values.yaml | |
token: ${{ secrets.GITHUB_TOKEN }} | |
matrix: | |
name: Generate matrix for build & scan | |
if: ${{ needs.release.outputs.release-created }} | |
runs-on: ubuntu-latest | |
needs: | |
- release | |
outputs: | |
build-matrix: ${{ steps.build-matrix.outputs.BUILD_MATRIX }} | |
steps: | |
- name: Checks-out repository | |
uses: actions/checkout@v3 | |
- name: Generate matrix for build | |
id: build-matrix | |
env: | |
TAG: "${{ needs.release.outputs.major-tag }}.${{ needs.release.outputs.minor-tag }}.${{ needs.release.outputs.patch-tag }},latest" | |
run: | | |
echo 'BUILD_MATRIX<<EOF' >> $GITHUB_OUTPUT | |
./ci/scripts/build-matrix.sh -f ./docker/docker-compose.prod.yml -c -p "${{ env.PLATFORM }}" -r "${{ env.REGISTRY }}" -t "${{ env.TAG }}" -n "${{ env.NAMESPACE }}" -a | jq '[.[] | select(.build != false)]' >> $GITHUB_OUTPUT | |
echo 'EOF' >> $GITHUB_OUTPUT | |
build: | |
name: Build application | |
runs-on: ubuntu-latest | |
needs: | |
- release | |
- matrix | |
strategy: | |
matrix: | |
images: ${{ fromJSON(needs.matrix.outputs.build-matrix) }} | |
steps: | |
- name: Checks-out repository | |
uses: actions/checkout@v3 | |
- name: Set up Docker buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Set up QEMU (for multi platform build) | |
uses: docker/setup-qemu-action@v2 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
logout: true | |
- name: Build docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: ${{ matrix.images.build.context }} | |
file: ${{ matrix.images.build.dockerfile }} | |
tags: ${{ matrix.images.build.tags }} | |
target: ${{ matrix.images.build.target }} | |
platforms: ${{ matrix.images.build.platforms }} | |
push: true | |
build-args: | | |
APP_VERSION=${{ needs.release.outputs.major-tag }}.${{ needs.release.outputs.minor-tag }}.${{ needs.release.outputs.patch-tag }} |