Skip to content

Commit

Permalink
Refactor GitHub Actions workflows
Browse files Browse the repository at this point in the history
-  Remove unnecessary lines in deploy.yml
-  Rename `validate-pr` job to `validate-labels` in pr_lint.yml and add concurrency settings
-  Modify the way of getting pull request data in pr_lint.yml
-  Add `validate-code`, `validate-docker-build`, and `validate-branch` jobs in pr_lint.yml with proper concurrency settings
-  In `validate-docker-build`, implement Docker image building and caching
-  Check branch name with version in `validate-branch` job
  • Loading branch information
jag-k committed Apr 9, 2024
1 parent e0fc01a commit e677811
Showing 1 changed file with 17 additions and 27 deletions.
44 changes: 17 additions & 27 deletions .github/workflows/pr_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
jobs:
validate-labels:
runs-on: ubuntu-latest
concurrency:
group: validate-pr
cancel-in-progress: true
steps:
- name: Check labels
uses: actions/github-script@v7
Expand Down Expand Up @@ -74,9 +71,6 @@ jobs:
validate-code:
runs-on: ubuntu-latest
concurrency:
group: validate-pr
cancel-in-progress: true
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
Expand Down Expand Up @@ -104,9 +98,25 @@ jobs:
run: |
echo "version=$(poetry version -s)" >> $GITHUB_OUTPUT
validate-branch:
runs-on: ubuntu-latest
needs:
- validate-code
if: startsWith(github.head_ref, 'release/')
steps:
- name: Check branch name with version
run: |
# Extract the branch name from the GitHub context
branch_name=${{ github.head_ref }}
# Check if the branch name starts with "release/" and does not match the version
if [[ $branch_name == release/* && $branch_name != "release/${{ needs.validate-code.outputs.version }}" ]]; then
echo "Branch name does not match the version in pyproject.toml"
exit 1
fi
validate-docker-build:
runs-on: ubuntu-latest
needs: validate-code
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -131,23 +141,3 @@ jobs:
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
platforms: linux/amd64,linux/arm64,linux/arm/v7

validate-branch:
runs-on: ubuntu-latest
needs:
- validate-code
concurrency:
group: validate-pr
cancel-in-progress: true
if: startsWith(github.head_ref, 'release/')
steps:
- name: Check branch name with version
run: |
# Extract the branch name from the GitHub context
branch_name=${{ github.head_ref }}
# Check if the branch name starts with "release/" and does not match the version
if [[ $branch_name == release/* && $branch_name != "release/${{ needs.validate-code.outputs.version }}" ]]; then
echo "Branch name does not match the version in pyproject.toml"
exit 1
fi

0 comments on commit e677811

Please sign in to comment.