Skip to content

Commit

Permalink
move environment-reporter src files and ci job to upload lambda packa…
Browse files Browse the repository at this point in the history
…ges to the separate repo
  • Loading branch information
zhelezovartem committed Feb 5, 2024
1 parent ab516a9 commit b904c6e
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 203 deletions.
25 changes: 1 addition & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,4 @@ jobs:
ghcr_user: ${{ secrets.GHCR_USER }}
ghcr_token: ${{ secrets.GHCR_TOKEN }}
kosli_api_token: ${{ secrets.KOSLI_API_TOKEN_PROD }}
snyk_token: ${{ secrets.SNYK_TOKEN }}

upload-kosli-reporter-package-staging:
needs: [pre-build, test]
if: ${{ github.ref == 'refs/heads/main' }}
uses: kosli-dev/cli/.github/workflows/upload-reporter-package.yml@main
with:
tag: ${{ needs.pre-build.outputs.tag }}
s3_name: reporter-lambda-stagingdacef8339fbd41ce31c346f854a85d0c74f7c4e8
AWS_ACCOUNT_ID: 772819027869
AWS_REGION: eu-central-1

deploy-staging-reporters:
runs-on: ubuntu-20.04
needs: [pre-build, upload-kosli-reporter-package-staging]
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.KOSLI_REPORTER_REPO_ACCESS_TOKEN }}
repository: kosli-dev/kosli-reporter
event-type: deploy-reporter
client-payload: '{"env": "staging", "tag": "${{ needs.pre-build.outputs.tag }}"}'
snyk_token: ${{ secrets.SNYK_TOKEN }}
282 changes: 138 additions & 144 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ name: release

on:
push:
tags:
- 'v*'
branches:
- move-env-reporter-src
# tags:
# - 'v*'

env:
GO_VERSION: 1.21.5
Expand All @@ -12,153 +14,145 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}

jobs:
pre-build:
runs-on: ubuntu-20.04
outputs:
tag: ${{ steps.tag.outputs.tag }}
steps:
# pre-build:
# runs-on: ubuntu-20.04
# outputs:
# tag: ${{ steps.tag.outputs.tag }}
# steps:

- uses: actions/checkout@v3

- name: Get tag
id: tag
uses: dawidd6/action-get-tag@v1

test:
needs: [pre-build]
if: ${{ github.ref != 'refs/heads/prod' }}
uses: kosli-dev/cli/.github/workflows/test.yml@main
with:
AWS_ACCOUNT_ID: 772819027869
AWS_REGION: eu-central-1
secrets:
github_access_token: ${{ secrets.KOSLI_GITHUB_TOKEN }}
gitlab_access_token: ${{ secrets.KOSLI_GITLAB_TOKEN }}
azure_access_token: ${{ secrets.KOSLI_AZURE_TOKEN }}
azure_service_token: ${{ secrets.KOSLI_AZURE_SERVICE_TOKEN }}
bitbucket_password: ${{ secrets.KOSLI_BITBUCKET_PASSWORD }}
slack_webhook: ${{ secrets.MERKELY_SLACK_CI_FAILURES_WEBHOOK }}
slack_channel: ${{ secrets.MERKELY_SLACK_CI_FAILURES_CHANNEL }}
jira_api_token: ${{ secrets.KOSLI_JIRA_API_TOKEN }}

docker:
needs: [test, pre-build]
if: ${{ github.ref != 'refs/heads/prod' }}
uses: kosli-dev/cli/.github/workflows/docker.yml@main
with:
tag: ${{ needs.pre-build.outputs.tag }}
platforms: linux/amd64
assert: true
secrets:
slack_webhook: ${{ secrets.MERKELY_SLACK_CI_FAILURES_WEBHOOK }}
slack_channel: ${{ secrets.MERKELY_SLACK_CI_FAILURES_CHANNEL }}
ghcr_user: ${{ secrets.GHCR_USER }}
ghcr_token: ${{ secrets.GHCR_TOKEN }}
kosli_api_token: ${{ secrets.KOSLI_API_TOKEN_PROD }}
snyk_token: ${{ secrets.SNYK_TOKEN }}

goreleaser:
needs: [test, docker]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GHCR_TOKEN }}
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}

homebrew-pr:
needs: [goreleaser, pre-build]
name: Bump Homebrew formula
runs-on: ubuntu-latest
steps:
- uses: mislav/bump-homebrew-formula-action@v3
if: ${{ !contains(github.ref, '-') }} # skip prereleases
with:
# A PR will be sent to github.com/Homebrew/homebrew-core to update this formula:
formula-name: kosli-cli
env:
# the personal access token should have "repo" & "workflow" scopes
COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}

docs-gen:
needs: [goreleaser, pre-build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # needed to be able to generate legacy versions reference.

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

- name: Generate docs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# legacy-ref should happen first as it has the side effect of deleting generated files outside the legacy_ref
run: |
make legacy-ref-docs
make cli-docs
- name: Generate json
run: |
echo '{"currentversion": "${{ needs.pre-build.outputs.tag }}"}' > docs.kosli.com/assets/metadata.json
- name: Deploy
uses: s0/git-publish-subdir-action@develop
env:
REPO: self
BRANCH: docs-main
FOLDER: docs.kosli.com
TARGET_DIR: docs.kosli.com
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MESSAGE: "Release: {msg}"

evidence-reporter-upload-package-and-deploy:
needs: [pre-build, goreleaser]
# - uses: actions/checkout@v3

# - name: Get tag
# id: tag
# uses: dawidd6/action-get-tag@v1

# test:
# needs: [pre-build]
# if: ${{ github.ref != 'refs/heads/prod' }}
# uses: kosli-dev/cli/.github/workflows/test.yml@main
# with:
# AWS_ACCOUNT_ID: 772819027869
# AWS_REGION: eu-central-1
# secrets:
# github_access_token: ${{ secrets.KOSLI_GITHUB_TOKEN }}
# gitlab_access_token: ${{ secrets.KOSLI_GITLAB_TOKEN }}
# azure_access_token: ${{ secrets.KOSLI_AZURE_TOKEN }}
# azure_service_token: ${{ secrets.KOSLI_AZURE_SERVICE_TOKEN }}
# bitbucket_password: ${{ secrets.KOSLI_BITBUCKET_PASSWORD }}
# slack_webhook: ${{ secrets.MERKELY_SLACK_CI_FAILURES_WEBHOOK }}
# slack_channel: ${{ secrets.MERKELY_SLACK_CI_FAILURES_CHANNEL }}
# jira_api_token: ${{ secrets.KOSLI_JIRA_API_TOKEN }}

# docker:
# needs: [test, pre-build]
# if: ${{ github.ref != 'refs/heads/prod' }}
# uses: kosli-dev/cli/.github/workflows/docker.yml@main
# with:
# tag: ${{ needs.pre-build.outputs.tag }}
# platforms: linux/amd64
# assert: true
# secrets:
# slack_webhook: ${{ secrets.MERKELY_SLACK_CI_FAILURES_WEBHOOK }}
# slack_channel: ${{ secrets.MERKELY_SLACK_CI_FAILURES_CHANNEL }}
# ghcr_user: ${{ secrets.GHCR_USER }}
# ghcr_token: ${{ secrets.GHCR_TOKEN }}
# kosli_api_token: ${{ secrets.KOSLI_API_TOKEN_PROD }}
# snyk_token: ${{ secrets.SNYK_TOKEN }}

# goreleaser:
# needs: [test, docker]
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# with:
# fetch-depth: 0

# - name: Set up Go
# uses: actions/setup-go@v3
# with:
# go-version: ${{ env.GO_VERSION }}

# - name: Run GoReleaser
# uses: goreleaser/goreleaser-action@v2
# with:
# version: latest
# args: release --clean
# env:
# GITHUB_TOKEN: ${{ secrets.GHCR_TOKEN }}
# FURY_TOKEN: ${{ secrets.FURY_TOKEN }}

# homebrew-pr:
# needs: [goreleaser, pre-build]
# name: Bump Homebrew formula
# runs-on: ubuntu-latest
# steps:
# - uses: mislav/bump-homebrew-formula-action@v3
# if: ${{ !contains(github.ref, '-') }} # skip prereleases
# with:
# # A PR will be sent to github.com/Homebrew/homebrew-core to update this formula:
# formula-name: kosli-cli
# env:
# # the personal access token should have "repo" & "workflow" scopes
# COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}

# docs-gen:
# needs: [goreleaser, pre-build]
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# with:
# fetch-depth: 0 # needed to be able to generate legacy versions reference.

# - name: Set up Go
# uses: actions/setup-go@v3
# with:
# go-version: ${{ env.GO_VERSION }}

# - name: Generate docs
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# # legacy-ref should happen first as it has the side effect of deleting generated files outside the legacy_ref
# run: |
# make legacy-ref-docs
# make cli-docs

# - name: Generate json
# run: |
# echo '{"currentversion": "${{ needs.pre-build.outputs.tag }}"}' > docs.kosli.com/assets/metadata.json

# - name: Deploy
# uses: s0/git-publish-subdir-action@develop
# env:
# REPO: self
# BRANCH: docs-main
# FOLDER: docs.kosli.com
# TARGET_DIR: docs.kosli.com
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# MESSAGE: "Release: {msg}"

# evidence-reporter-upload-package-and-deploy:
# needs: [pre-build, goreleaser]
# runs-on: ubuntu-20.04
# steps:
# - name: Repository Dispatch
# uses: peter-evans/repository-dispatch@v2
# with:
# token: ${{ secrets.KOSLI_REPORTER_REPO_ACCESS_TOKEN }}
# repository: kosli-dev/terraform-aws-evidence-reporter
# event-type: upload-package
# client-payload: '{"kosli_cli_tag": "${{ needs.pre-build.outputs.tag }}"}'

environment-reporter-upload-package-and-deploy:
# needs: [pre-build, goreleaser]
runs-on: ubuntu-20.04
steps:
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.KOSLI_REPORTER_REPO_ACCESS_TOKEN }}
repository: kosli-dev/terraform-aws-evidence-reporter
repository: kosli-dev/terraform-aws-kosli-reporter
event-type: upload-package
client-payload: '{"kosli_cli_tag": "${{ needs.pre-build.outputs.tag }}"}'

upload-kosli-reporter-package-prod:
needs: [pre-build, goreleaser]
uses: kosli-dev/cli/.github/workflows/upload-reporter-package.yml@main
with:
tag: ${{ needs.pre-build.outputs.tag }}
s3_name: reporter-lambda-dacef8339fbd41ce31c346f854a85d0c74f7c4e8
AWS_ACCOUNT_ID: 772819027869
AWS_REGION: eu-central-1

deploy-production-reporters:
runs-on: ubuntu-20.04
needs: [pre-build, upload-kosli-reporter-package-prod]
steps:
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.KOSLI_REPORTER_REPO_ACCESS_TOKEN }}
repository: kosli-dev/kosli-reporter
event-type: deploy-reporter
client-payload: '{"env": "production", "tag": "${{ needs.pre-build.outputs.tag }}"}'
# client-payload: '{"kosli_cli_tag": "${{ needs.pre-build.outputs.tag }}"}'
client-payload: '{"kosli_cli_tag": "test"}'
7 changes: 0 additions & 7 deletions bin/upload_reporter_package.sh

This file was deleted.

23 changes: 0 additions & 23 deletions deployment/reporter-lambda-src/bootstrap

This file was deleted.

5 changes: 0 additions & 5 deletions deployment/reporter-lambda-src/function.sh

This file was deleted.

0 comments on commit b904c6e

Please sign in to comment.