Initialize repository with Readme, CI pipelines and others #1
Workflow file for this run
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: Branch and PR build | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
env: | |
GOLANGCI_LINT_TIMEOUT: 5m | |
GORELEASER_CURRENT_TAG: "v0.0.0-latest" | |
BUCKET_NAME: botkube-cloud-plugins-latest | |
jobs: | |
cancel-previous-workflows: | |
name: Cancel previous workflows | |
runs-on: ubuntu-latest | |
if: github.event.pull_request.draft == false | |
# https://github.com/styfle/cancel-workflow-action#advanced-token-permissions | |
permissions: | |
actions: write | |
steps: | |
- name: Cancel Previous Runs | |
uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 | |
with: | |
access_token: ${{ github.token }} | |
lint-test: | |
name: Lint and test | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Checkout code" | |
uses: actions/checkout@v4 | |
- name: "Set up Go" | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
- name: "Check code quality" | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
args: --timeout=${{ env.GOLANGCI_LINT_TIMEOUT }} | |
- name: "Run tests" | |
run: make test | |
build-plugins: | |
if: github.event_name == 'pull_request' | |
name: Build plugins without publish | |
runs-on: ubuntu-latest | |
needs: lint-test | |
steps: | |
- name: "Checkout code" | |
uses: actions/checkout@v4 | |
- name: "Set up Go" | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
- name: Install GoReleaser | |
uses: goreleaser/goreleaser-action@v5 | |
with: | |
install-only: true | |
version: latest | |
- name: Build plugins and generate plugins index.yaml | |
env: | |
PLUGIN_DOWNLOAD_URL_BASE_PATH: "" | |
run: | | |
make build-plugins-archives | |
USE_ARCHIVE=true make gen-plugin-index | |
release-latest-plugins: | |
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' | |
name: Build and release latest plugins | |
runs-on: ubuntu-latest | |
needs: lint-test | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: GCP auth | |
uses: 'google-github-actions/auth@v2' | |
with: | |
credentials_json: ${{ secrets.CLOUD_PLUGINS_LATEST_BUCKET_CREDS }} | |
- name: 'Set up Cloud SDK' | |
uses: 'google-github-actions/setup-gcloud@v2' | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
- name: Install GoReleaser | |
uses: goreleaser/goreleaser-action@v5 | |
with: | |
install-only: true | |
version: latest | |
- name: Build plugins and generate plugins index.yaml | |
env: | |
PLUGIN_DOWNLOAD_URL_BASE_PATH: "" | |
run: | | |
make build-plugins-archives | |
USE_ARCHIVE=true make gen-plugin-index | |
- name: Upload plugins to GCS | |
uses: google-github-actions/upload-cloud-storage@v2 | |
with: | |
path: 'dist' | |
destination: '${{ env.BUCKET_NAME }}/' | |
glob: '*.tar.gz' | |
parent: false | |
- name: Upload plugin index to GCS | |
uses: google-github-actions/upload-cloud-storage@v2 | |
with: | |
path: 'plugins-index.yaml' | |
destination: '${{ env.BUCKET_NAME }}/' | |
- name: 'Disable GCS caching' | |
run: 'gsutil -m setmeta -h "Cache-Control: no-cache, no-store" gs://${{ env.BUCKET_NAME }}/*' |