From ba630779e13a02961d38dd727f089215f11cef75 Mon Sep 17 00:00:00 2001 From: Joshua Kiwiet-Pantaleoni Date: Tue, 7 Nov 2023 17:11:17 -0800 Subject: [PATCH 1/3] feat: run release and release build in same workflow --- .github/workflows/create-release.yaml | 40 ---------------- .github/workflows/semantic-release.yaml | 64 ++++++++++++++++++++++--- 2 files changed, 57 insertions(+), 47 deletions(-) delete mode 100644 .github/workflows/create-release.yaml diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml deleted file mode 100644 index a97324ffd9..0000000000 --- a/.github/workflows/create-release.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: create-release - -on: - workflow_dispatch: - inputs: - pre_release: - description: "Should this be a pre-release for staging?" - required: true - type: boolean - default: true - pre_release_branch: - description: "Branch to use for pre-release" - required: false - type: string - default: "main" - -jobs: - create-release: - runs-on: ubuntu-latest - steps: - - name: checkout-repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - fetch-tags: true - token: ${{ secrets.KIVA_ROBOT_GITHUB_PAT }} - - name: checkout-actions - uses: actions/checkout@v4 - with: - repository: kiva/github-actions - token: ${{ secrets.KIVA_ROBOT_GITHUB_PAT }} - path: .github/ - - name: create-release - id: release - uses: ./.github/actions/start-semantic-release - env: - GITHUB_PAT: ${{ secrets.KIVA_ROBOT_GITHUB_PAT }} - with: - pre_release: "${{ github.event.inputs.pre_release }}" - pre_release_branch: ${{ github.event.inputs.pre_release_branch }} diff --git a/.github/workflows/semantic-release.yaml b/.github/workflows/semantic-release.yaml index 2dff706ccf..8ef4b5823b 100644 --- a/.github/workflows/semantic-release.yaml +++ b/.github/workflows/semantic-release.yaml @@ -1,32 +1,82 @@ name: Semantic Release on: - push: - branches: - - staging - - production + workflow_dispatch: + inputs: + environment: + type: choice + description: 'Environment to release to. Select "staging" for a pre-release or "production" for a full release.' + options: + - staging + - production + required: true jobs: + # Create a release create-release: runs-on: ubuntu-latest + outputs: + published: ${{ steps.release.outputs.published }} + tag: ${{ steps.release.outputs.tag }} steps: - - name: checkout-repo + - name: Checkout repo uses: actions/checkout@v4 with: fetch-depth: 0 fetch-tags: true persist-credentials: false token: ${{ secrets.KIVA_ROBOT_GITHUB_PAT }} - - name: checkout-actions + - name: Checkout actions uses: actions/checkout@v4 with: repository: kiva/github-actions token: ${{ secrets.KIVA_ROBOT_GITHUB_PAT }} persist-credentials: false path: .github/ - - name: semantic-release + - name: Run semantic-release + id: release uses: ./.github/actions/semantic-release env: GITHUB_PAT: ${{ secrets.KIVA_ROBOT_GITHUB_PAT }} with: config: "node" + + # Build and push the image to ECR if the release was published + build-image: + runs-on: ubuntu-latest + needs: create-release + if: needs.create-release.outputs.published == 'true' + 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" + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ needs.create-release.outputs.tag }} + - 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: main + patterns: | + resources/org/kiva/marketplaceWebUiCi/ui + - name: move files + run: | + mv .docker/resources/org/kiva/marketplaceWebUiCi/ui/Dockerfile . + - name: docker-build + uses: ./.github/actions/docker-build-push + if: github.event_name == 'pull_request' + with: + dockerfile_target: "release" + push: false From c95589a5e3200ce69181437cb984b9ac3d4ed342 Mon Sep 17 00:00:00 2001 From: Joshua Kiwiet-Pantaleoni Date: Wed, 8 Nov 2023 09:26:51 -0800 Subject: [PATCH 2/3] fix: ensure docker build push runs for successful semantic releases --- .github/workflows/semantic-release.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/semantic-release.yaml b/.github/workflows/semantic-release.yaml index 8ef4b5823b..9983a5376f 100644 --- a/.github/workflows/semantic-release.yaml +++ b/.github/workflows/semantic-release.yaml @@ -55,10 +55,10 @@ jobs: SLACK_CHANNEL: "eng-build-failures" steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ needs.create-release.outputs.tag }} - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: kiva/github-actions token: ${{ env.GITHUB_PAT }} @@ -70,13 +70,12 @@ jobs: path: .docker ref: main patterns: | - resources/org/kiva/marketplaceWebUiCi/ui + resources/org/kiva/marketplaceWebUiCi/ui - name: move files run: | mv .docker/resources/org/kiva/marketplaceWebUiCi/ui/Dockerfile . - name: docker-build uses: ./.github/actions/docker-build-push - if: github.event_name == 'pull_request' with: dockerfile_target: "release" - push: false + push: true From 7719f7d19c226ed5ef6bfc611d105d16a1a87d50 Mon Sep 17 00:00:00 2001 From: Joshua Kiwiet-Pantaleoni Date: Wed, 8 Nov 2023 09:44:56 -0800 Subject: [PATCH 3/3] fix: remove previous build process for tags --- .github/workflows/release-build.yaml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release-build.yaml b/.github/workflows/release-build.yaml index 43ed3d3e96..2fbc713e50 100644 --- a/.github/workflows/release-build.yaml +++ b/.github/workflows/release-build.yaml @@ -5,9 +5,6 @@ on: push: branches: - main - tags: - - 'v[0-9]+.[0-9]+.[0-9]+' - - 'v[0-9]+.[0-9]+.[0-9]+-rc*' env: GITHUB_PAT: "${{ secrets.KIVA_ROBOT_GITHUB_PAT }}" @@ -55,8 +52,8 @@ jobs: # Build and push the image to ECR build: runs-on: ubuntu-latest - # Run on merges to development or tag pushes (done by create-release workflow) - if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags') + # Run on merges to development (main) + if: github.ref == 'refs/heads/main' steps: - name: Checkout uses: actions/checkout@v3