From fc2a7b55537269ad3ad717401d196c294b6186e7 Mon Sep 17 00:00:00 2001 From: kathrynlovett Date: Thu, 19 Oct 2023 15:16:03 -0700 Subject: [PATCH] chore: [CP-603] First attempt at setting up release flow --- .github/workflows/build-push-test.yaml | 51 ++++++++++++++++++++++++++ .github/workflows/create-release.yaml | 34 +++++++++++++++++ .github/workflows/lint-name.yaml | 23 ++++++++++++ .github/workflows/release-build.yaml | 47 ++++++++++++++++++++++++ 4 files changed, 155 insertions(+) create mode 100644 .github/workflows/build-push-test.yaml create mode 100644 .github/workflows/create-release.yaml create mode 100644 .github/workflows/lint-name.yaml create mode 100644 .github/workflows/release-build.yaml diff --git a/.github/workflows/build-push-test.yaml b/.github/workflows/build-push-test.yaml new file mode 100644 index 0000000000..0403b9c78e --- /dev/null +++ b/.github/workflows/build-push-test.yaml @@ -0,0 +1,51 @@ +name: Docker Build Test + +on: + pull_request: + push: + tags: + - 'v*' + +env: + AWS_REGION: "us-west-2" + AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}" + AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}" + GITHUB_PAT: "${{ secrets.KIVA_ROBOT_GITHUB_PAT }}" + SLACK_BOT_TOKEN: "${{ secrets.SLACK_TOKEN }}" + SLACK_CHANNEL: "eng-build-failures" + +jobs: + # Test that the image actually builds on each commit + build-push-test: + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + steps: + - name: Checkout + uses: actions/checkout@v3 + - uses: actions/checkout@v3 + with: + repository: kiva/github-actions + token: ${{ env.GITHUB_PAT }} + path: .github/ + - uses: snow-actions/sparse-checkout@v1.2.0 + with: + repository: kiva/marketplace-web-ui-ci + token: ${{ env.GITHUB_PAT }} + path: .docker + ref: ui-static + patterns: | + resources/org/kiva/marketplaceWebUiCi/ui + + - name: move files + run: | + mv .docker/resources/org/kiva/marketplaceWebUiCi/ui/Dockerfile . + cp -aRv .docker/resources/org/kiva/marketplaceWebUiCi/ui/config . + + - name: docker-build + uses: ./.github/actions/docker-build-push + if: github.event_name == 'pull_request' + with: + build_args: | + TARGET_ENV=dev + dockerfile_target: "release" + push: false diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml new file mode 100644 index 0000000000..f5794042a5 --- /dev/null +++ b/.github/workflows/create-release.yaml @@ -0,0 +1,34 @@ +name: create-release + +on: + workflow_dispatch: + inputs: + environment: + type: choice + description: 'Environment to release to (staging or production)' + options: + - staging + - production + required: true + +jobs: + create-release: + runs-on: ubuntu-latest + steps: + - name: checkout-repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + - name: checkout-actions + uses: actions/checkout@v4 + with: + repository: kiva/github-actions + token: ${{ secrets.KIVA_ROBOT_GITHUB_PAT }} + path: .github/ + - name: create-release + uses: ./.github/actions/create-release + env: + GITHUB_PAT: ${{ secrets.KIVA_ROBOT_GITHUB_PAT }} + with: + environment: ${{ github.event.inputs.environment }} diff --git a/.github/workflows/lint-name.yaml b/.github/workflows/lint-name.yaml new file mode 100644 index 0000000000..6b06136c2b --- /dev/null +++ b/.github/workflows/lint-name.yaml @@ -0,0 +1,23 @@ +name: Lint PR (semantic title) + +on: + pull_request: + types: + - opened + - synchronize + - edited + +jobs: + lint-title: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/checkout@v3 + with: + repository: kiva/github-actions + token: ${{ secrets.KIVA_ROBOT_GITHUB_PAT }} + path: .github/ + - name: lint-pr + uses: ./.github/actions/lint-pr + env: + GITHUB_PAT: ${{ secrets.KIVA_ROBOT_GITHUB_PAT }} diff --git a/.github/workflows/release-build.yaml b/.github/workflows/release-build.yaml new file mode 100644 index 0000000000..6b51c0fdca --- /dev/null +++ b/.github/workflows/release-build.yaml @@ -0,0 +1,47 @@ +name: Docker Build Publish + +on: + release: + types: [published] + push: + branches: + - main + +env: + GITHUB_PAT: "${{ secrets.KIVA_ROBOT_GITHUB_PAT }}" + AWS_REGION: "us-west-2" + AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}" + AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}" + SLACK_BOT_TOKEN: "${{ secrets.SLACK_TOKEN }}" + SLACK_CHANNEL: "eng-build-failures" + +jobs: + # Build and push the image to ECR + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Checkout actions + uses: actions/checkout@v3 + with: + repository: kiva/github-actions + token: ${{ env.GITHUB_PAT }} + path: .github/ + - uses: snow-actions/sparse-checkout@v1.2.0 + with: + repository: kiva/marketplace-web-ui-ci + token: ${{ env.GITHUB_PAT }} + path: .docker + patterns: | + resources/org/kiva/marketplaceWebUiCi/ui + - name: move files + run: | + mv .docker/resources/org/kiva/marketplaceWebUiCi/ui/Dockerfile . + cp -aRv .docker/resources/org/kiva/marketplaceWebUiCi/ui/config . + - name: docker-push + uses: ./.github/actions/docker-build-push + with: + dockerfile_target: "release" + push: true