Merge pull request #3 from opengovern/feat-make-task #48
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: Build and Deploy | |
on: | |
workflow_dispatch: | |
push: | |
branches: ["main", "dev"] | |
jobs: | |
build: | |
environment: main | |
env: | |
GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} | |
runs-on: ubuntu-latest | |
outputs: | |
latest_tag: ${{ steps.set_latest_tag.outputs.latest_tag }} | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Install musl cc | |
uses: awalsh128/[email protected] | |
with: | |
packages: musl-tools musl-dev musl | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: './go.mod' | |
cache: false # Disable built-in caching to use custom caching | |
- name: Tag Version | |
id: tag_version | |
uses: mathieudutour/[email protected] | |
with: | |
github_token: ${{ secrets.GH_ACCESS_TOKEN }} | |
release_branches: main | |
tag_prefix: v | |
- name: Cache Go Modules and Build Cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/go/pkg/mod | |
~/.cache/go-build | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.mod') }}-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go-${{ hashFiles('**/go.mod') }}- | |
${{ runner.os }}-go- | |
- name: Build Kubernetes Plugin App | |
working-directory: ./cloudql | |
run: make build | |
- name: Pack Kubernetes Plugin Build | |
working-directory: ./cloudql | |
run: | | |
tar -cvf build.tar build | |
- name: Upload Kubernetes Plugin Artifact | |
uses: actions/[email protected] | |
with: | |
name: steampipe-plugin-kubernetes | |
path: ./cloudql/build.tar | |
retention-days: 1 | |
- name: Build Local Describer App | |
working-directory: ./discovery | |
run: make build-describer | |
- name: Pack Local Describer Build | |
working-directory: ./discovery | |
run: | | |
tar -cvf local.tar local | |
- name: Upload Local Artifact | |
uses: actions/[email protected] | |
with: | |
name: local-og-describer-kubernetes | |
path: ./discovery/local.tar | |
retention-days: 1 | |
- name: Add Tag to Release | |
run: | | |
echo "new_tag=${{ steps.tag_version.outputs.new_tag }}" >> "$GITHUB_OUTPUT" | |
export TAG=${{ steps.tag_version.outputs.new_tag }} | |
./update-manifest.sh | |
working-directory: ./platform/constants | |
- name: Check manifest file | |
run: cat ./platform/constants/manifest.yaml | |
- name: Build Integration Plugin | |
working-directory: ./platform | |
run: make build | |
- name: Create output directory | |
working-directory: . | |
run: mkdir -p kubernetes-plugin | |
- name: Copy steampipe plugin to output directory | |
working-directory: . | |
run: cp ./cloudql/build/steampipe-plugin-kubernetes.plugin ./kubernetes-plugin/cloudql-plugin | |
- name: Copy integration plugin to output directory | |
working-directory: . | |
run: cp ./platform/build/integration-plugin ./kubernetes-plugin/ | |
- name: Copy manifest to output directory | |
working-directory: . | |
run: cp ./platform/constants/manifest.yaml ./kubernetes-plugin/ | |
- name: Copy index templates folder to output directory | |
working-directory: . | |
run: cp -r ./platform/index-templates ./kubernetes-plugin/ | |
- name: Pack output | |
working-directory: . | |
run: | | |
tar -czf kubernetes-plugin.tar kubernetes-plugin | |
- name: Upload kubernetes outputs artifact | |
uses: actions/[email protected] | |
with: | |
name: kubernetes-plugins | |
path: ./kubernetes-plugin.tar | |
retention-days: 1 | |
- name: Set Latest Tag Output | |
id: set_latest_tag | |
run: | | |
if [[ -z "${{ steps.tag_version.outputs.new_tag }}" ]]; then | |
echo "latest_tag=${{ steps.tag_version.outputs.previous_tag }}" >> "$GITHUB_OUTPUT" | |
else | |
echo "latest_tag=${{ steps.tag_version.outputs.new_tag }}" >> "$GITHUB_OUTPUT" | |
fi | |
deploy-kubernetes-plugin: | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
environment: main | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Download Kubernetes Plugin Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: steampipe-plugin-kubernetes | |
path: . | |
- name: Unpack Kubernetes Plugin Artifact | |
run: | | |
tar -xvf build.tar | |
- name: Log in to Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GHCR_PAT }} | |
- name: Build and Push Docker Image for Kubernetes Plugin | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
tags: | | |
ghcr.io/${{ github.repository_owner }}/steampipe-plugin-kubernetes:0.0.1 | |
ghcr.io/${{ github.repository_owner }}/steampipe-plugin-kubernetes:${{ needs.build.outputs.latest_tag }} | |
file: cloudql/docker/Dockerfile | |
context: . | |
deploy-local-describer: | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
environment: main | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Download Local Describer Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: local-og-describer-kubernetes | |
path: . | |
- name: Unpack Local Describer Artifact | |
run: | | |
tar -xvf local.tar | |
- name: Log in to Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GHCR_PAT }} | |
- name: Build and Push Docker Image for Local Describer | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
tags: | | |
ghcr.io/${{ github.repository_owner }}/og-describer-kubernetes:local-latest | |
ghcr.io/${{ github.repository_owner }}/og-describer-kubernetes:local-${{ needs.build.outputs.latest_tag }} | |
file: discovery/DockerFile | |
context: . | |
release-integration-plugin: | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: write | |
environment: main | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Download Integration Plugin Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: kubernetes-plugins | |
- name: Unpack Integration Plugin Artifact | |
run: | | |
tar -xvf kubernetes-plugin.tar | |
- name: Pack folder content into a zip file for release | |
run: | | |
cd kubernetes-plugin | |
zip -r kubernetes-plugin.zip . | |
- name: Release Integration Plugin | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: ./kubernetes-plugin/kubernetes-plugin.zip | |
tag_name: ${{ needs.build.outputs.latest_tag }} |