From 0376e767289ac7af6b401432cd8082c86e439502 Mon Sep 17 00:00:00 2001 From: Antti Harju Date: Fri, 9 Aug 2024 09:28:28 +0300 Subject: [PATCH] Migrate CI away from erb templates (#643) --- .github/templates/jobs/build.erb | 24 ----- .github/templates/jobs/test.erb | 35 ------- .github/templates/pull_request.yml.erb | 27 ------ .github/templates/release.yml.erb | 26 ------ .../{release.generated.yml => build.yml} | 32 +++---- .github/workflows/pull_request.generated.yml | 93 ------------------- .github/workflows/pull_request.yml | 11 +++ .github/workflows/release.yml | 11 +++ README.md | 4 +- 9 files changed, 35 insertions(+), 228 deletions(-) delete mode 100644 .github/templates/jobs/build.erb delete mode 100644 .github/templates/jobs/test.erb delete mode 100644 .github/templates/pull_request.yml.erb delete mode 100644 .github/templates/release.yml.erb rename .github/workflows/{release.generated.yml => build.yml} (70%) delete mode 100644 .github/workflows/pull_request.generated.yml create mode 100644 .github/workflows/pull_request.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/templates/jobs/build.erb b/.github/templates/jobs/build.erb deleted file mode 100644 index e8df0621..00000000 --- a/.github/templates/jobs/build.erb +++ /dev/null @@ -1,24 +0,0 @@ -build: - runs-on: <%= ubuntu_version %> - steps: - - uses: actions/checkout@v2 - - name: Set Node.js 16.x - uses: actions/setup-node@v3 - with: - node-version: 16.x - - name: "Install" - run: | - npm install - - name: "Prettier" - run: | - npm run format-check - - name: "Lint" - run: | - npm run lint - - name: "Test" - run: | - npm run test - - name: "build" - run: | - npm run build - npm run package diff --git a/.github/templates/jobs/test.erb b/.github/templates/jobs/test.erb deleted file mode 100644 index 1ca14974..00000000 --- a/.github/templates/jobs/test.erb +++ /dev/null @@ -1,35 +0,0 @@ -test: - runs-on: <%= ubuntu_version %> - steps: - - uses: actions/checkout@v2 - - name: Set Node.js 16.x - uses: actions/setup-node@v3 - with: - node-version: 16.x - - name: "Build action for test" - run: | - npm install - npm run all - git clean -fXd - - name: Mock the kubectl binary - run: | - echo "$(pwd)/__tests__/bin" >> "$GITHUB_PATH" - - name: Check if deployment is locked - uses: ./ - with: - serviceName: test-service - kubernetesContext: test-context - command: isLocked - - name: Unlock deployments - uses: ./ - with: - serviceName: test-service - kubernetesContext: test-context - command: unlock - - name: Lock deployments - uses: ./ - with: - serviceName: test-service - kubernetesContext: test-context - command: lock - user: github-actions diff --git a/.github/templates/pull_request.yml.erb b/.github/templates/pull_request.yml.erb deleted file mode 100644 index 294e87b2..00000000 --- a/.github/templates/pull_request.yml.erb +++ /dev/null @@ -1,27 +0,0 @@ -name: "Pull Request" - -on: - pull_request: - branches: [master] - -jobs: - @import ./jobs/build - - @import ./jobs/test - - release: - runs-on: <%= ubuntu_version %> - name: "Build and release action" - needs: [build, test] - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - persist-credentials: true - - name: Configure git - uses: smartlyio/github-actions@git-init-userinfo-v1 - - name: Release flow - uses: smartlyio/github-actions@release-action-node-v1 - with: - dry_run: true - token: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file diff --git a/.github/templates/release.yml.erb b/.github/templates/release.yml.erb deleted file mode 100644 index 080d86fb..00000000 --- a/.github/templates/release.yml.erb +++ /dev/null @@ -1,26 +0,0 @@ -name: Build and release the action - -on: - push: - branches: [master] - -jobs: - @import ./jobs/build - - @import ./jobs/test - - release: - runs-on: <%= ubuntu_version %> - name: "Build and release action" - needs: [build, test] - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - persist-credentials: true - - name: Configure git - uses: smartlyio/github-actions@git-init-userinfo-v1 - - name: Release flow - uses: smartlyio/github-actions@release-action-node-v1 - with: - token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/release.generated.yml b/.github/workflows/build.yml similarity index 70% rename from .github/workflows/release.generated.yml rename to .github/workflows/build.yml index a02e65b1..8d35da1b 100644 --- a/.github/workflows/release.generated.yml +++ b/.github/workflows/build.yml @@ -1,25 +1,14 @@ -# IMPORTANT NOTE/WARNING! -# Do not make changes to this file, your changes will be overwritten. -# -# This file is automagically generated from: -# - .github/templates/release.yml.erb -# - Templates contained in the smartlyio/github-actions-templates repository -# -# This file can be updated by editing the template file, and running `devbox render workflows` +name: Build -name: Build and release the action - -on: - push: - branches: [master] +on: workflow_call jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set Node.js 16.x - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 16.x - name: "Install" @@ -40,11 +29,11 @@ jobs: npm run package test: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set Node.js 16.x - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 16.x - name: "Build action for test" @@ -76,11 +65,11 @@ jobs: user: github-actions release: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 name: "Build and release action" needs: [build, test] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 persist-credentials: true @@ -89,4 +78,5 @@ jobs: - name: Release flow uses: smartlyio/github-actions@release-action-node-v1 with: + dry_run: ${{ github.event_name == 'pull_request' }} token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/pull_request.generated.yml b/.github/workflows/pull_request.generated.yml deleted file mode 100644 index 723fe61b..00000000 --- a/.github/workflows/pull_request.generated.yml +++ /dev/null @@ -1,93 +0,0 @@ -# IMPORTANT NOTE/WARNING! -# Do not make changes to this file, your changes will be overwritten. -# -# This file is automagically generated from: -# - .github/templates/pull_request.yml.erb -# - Templates contained in the smartlyio/github-actions-templates repository -# -# This file can be updated by editing the template file, and running `devbox render workflows` - -name: "Pull Request" - -on: - pull_request: - branches: [master] - -jobs: - build: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - name: Set Node.js 16.x - uses: actions/setup-node@v3 - with: - node-version: 16.x - - name: "Install" - run: | - npm install - - name: "Prettier" - run: | - npm run format-check - - name: "Lint" - run: | - npm run lint - - name: "Test" - run: | - npm run test - - name: "build" - run: | - npm run build - npm run package - - test: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - name: Set Node.js 16.x - uses: actions/setup-node@v3 - with: - node-version: 16.x - - name: "Build action for test" - run: | - npm install - npm run all - git clean -fXd - - name: Mock the kubectl binary - run: | - echo "$(pwd)/__tests__/bin" >> "$GITHUB_PATH" - - name: Check if deployment is locked - uses: ./ - with: - serviceName: test-service - kubernetesContext: test-context - command: isLocked - - name: Unlock deployments - uses: ./ - with: - serviceName: test-service - kubernetesContext: test-context - command: unlock - - name: Lock deployments - uses: ./ - with: - serviceName: test-service - kubernetesContext: test-context - command: lock - user: github-actions - - release: - runs-on: ubuntu-20.04 - name: "Build and release action" - needs: [build, test] - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - persist-credentials: true - - name: Configure git - uses: smartlyio/github-actions@git-init-userinfo-v1 - - name: Release flow - uses: smartlyio/github-actions@release-action-node-v1 - with: - dry_run: true - token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 00000000..929dda6c --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,11 @@ +name: Pull Request + +on: + pull_request: + branches: [master] + +jobs: + build: + name: Build + uses: ./.github/workflows/build.yml + secrets: inherit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..8c67f0b6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,11 @@ +name: Release + +on: + push: + branches: [master] + +jobs: + build: + name: Build + uses: ./.github/workflows/build.yml + secrets: inherit diff --git a/README.md b/README.md index 6c433499..490942ff 100644 --- a/README.md +++ b/README.md @@ -42,10 +42,10 @@ on: jobs: is_locked: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 id: is_locked steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Authenticate with the cluster env: KUBERNETES_AUTH_TOKEN: ${{ secrets.KUBERNETES_AUTH_TOKEN }}