Skip to content

Commit

Permalink
Optimize gh build action
Browse files Browse the repository at this point in the history
  • Loading branch information
ogesaku committed Oct 14, 2024
1 parent cc70cee commit a54adec
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
37 changes: 24 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,49 +15,60 @@ jobs:
# Skip duplicate build on pull_request if pull request uses branch from the same repository
if: github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name
steps:
- name: Skip build
id: skipper
uses: fkirc/skip-duplicate-actions@v5
with:
paths_ignore: '["*.md", ".github/**.md", ".gitignore", "docs/**", "gradle.properties"]'
skip_summary: true

- name: Checkout
uses: actions/checkout@v4
if: steps.skipper.outputs.should_skip != 'true'
with:
# Required to deduce version from git tags
fetch-depth: 0

- name: Skip build
id: skipper
run: |
if [ "${{ github.event_name }}" == 'pull_request' ]; then
CHANGED_FILES="$(git diff --name-only -r HEAD^1 HEAD)"
else
CHANGED_FILES="$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})"
fi
NOT_SKIPPED="$(echo "$CHANGED_FILES" \
| grep -v -e "^[^/]*\.md" -e "^.github/.*\.md" -e "^.gitignore" -e "^docs/.*" -e "^gradle.properties" \
|| echo "")"
echo -e ">>> Changed files:\n$CHANGED_FILES"
echo -e ">>> Not skipped files:\n$NOT_SKIPPED"
if [ -z "$NOT_SKIPPED" ]; then
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "skip=false" >> $GITHUB_OUTPUT
fi
- name: Setup JDK
uses: actions/setup-java@v4
if: steps.skipper.outputs.should_skip != 'true'
if: steps.skipper.outputs.skip != 'true'
with:
java-version: 21
distribution: temurin

- name: Validate gradle wrapper
uses: gradle/actions/wrapper-validation@v4
if: steps.skipper.outputs.should_skip != 'true'
if: steps.skipper.outputs.skip != 'true'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
if: steps.skipper.outputs.should_skip != 'true'
if: steps.skipper.outputs.skip != 'true'
with:
# Publish dependency graph only for the default branch
dependency-graph: |
${{ (github.event.repository != null && github.ref_name == github.event.repository.default_branch)
&& 'generate-and-submit' || 'disabled' }}
- name: Build
if: steps.skipper.outputs.should_skip != 'true'
if: steps.skipper.outputs.skip != 'true'
run: ./gradlew build

- name: Publish Coverage Report
uses: codecov/codecov-action@v4
# Publish coverage only for the default branch
if: |
steps.skipper.outputs.should_skip != 'true'
steps.skipper.outputs.skip != 'true'
&& github.event.repository != null
&& github.ref_name == github.event.repository.default_branch
with:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,9 @@ jobs:
-f tag_name="v$NEXT_VERSION" \
-f previous_tag_name="$PREV_TAG_NAME" \
| jq -r '.body')"
declare -r ESCAPED="${NOTES//$'\n'/'%0A'}"
echo "notes=$ESCAPED" >> $GITHUB_OUTPUT
echo 'notes<<EOF' >> $GITHUB_OUTPUT
echo "$NOTES" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Create github release
if: steps.notes.conclusion == 'success'
Expand Down

0 comments on commit a54adec

Please sign in to comment.