[core] has recent
This commit is contained in:
1 parent
b5b491cb7b
commit
f8cb56525a
1 file changed
+15
-43
+15
-43
@@ -34,46 +34,28 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Determine baseline commit
|
||||
id: baseline
|
||||
- name: Check recent changes
|
||||
id: recent
|
||||
run: |
|
||||
base_sha=$(git rev-list -n 1 --before="24 hours ago" "$GITHUB_SHA" || true)
|
||||
force_recent=false
|
||||
if [ -z "$base_sha" ]; then
|
||||
base_sha=$(git rev-parse "$GITHUB_SHA")
|
||||
force_recent=true
|
||||
count=$(git rev-list --after="24 hours ago" --count HEAD || true)
|
||||
if [ "$count" -gt 0 ]; then
|
||||
echo "has_recent=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "has_recent=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
echo "sha=$base_sha" >> "$GITHUB_OUTPUT"
|
||||
echo "force_recent=$force_recent" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Detect recent changes
|
||||
id: recent_changes
|
||||
uses: dorny/paths-filter@v3
|
||||
with:
|
||||
base: ${{ steps.baseline.outputs.sha }}
|
||||
head: ${{ github.sha }}
|
||||
filters: |
|
||||
repo:
|
||||
- '**'
|
||||
|
||||
- name: No recent changes summary
|
||||
if:
|
||||
${{ steps.baseline.outputs.force_recent != 'true' &&
|
||||
steps.recent_changes.outputs.repo != 'true' }}
|
||||
if: ${{ steps.recent.outputs.has_recent != 'true' }}
|
||||
run:
|
||||
echo "No commits in the last 24 hours; skipping build." >>
|
||||
"$GITHUB_STEP_SUMMARY"
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
if:
|
||||
${{ steps.baseline.outputs.force_recent == 'true' ||
|
||||
steps.recent_changes.outputs.repo == 'true' }}
|
||||
if: ${{ steps.recent.outputs.has_recent == 'true' }}
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Docker meta
|
||||
if:
|
||||
${{ steps.baseline.outputs.force_recent == 'true' ||
|
||||
steps.recent_changes.outputs.repo == 'true' }}
|
||||
if: ${{ steps.recent.outputs.has_recent == 'true' }}
|
||||
id: meta
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
@@ -83,18 +65,14 @@ jobs:
|
||||
type=raw,value=${{ matrix.tag }}
|
||||
|
||||
- name: Login to image repository
|
||||
if:
|
||||
${{ steps.baseline.outputs.force_recent == 'true' ||
|
||||
steps.recent_changes.outputs.repo == 'true' }}
|
||||
if: ${{ steps.recent.outputs.has_recent == 'true' }}
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USER }}
|
||||
password: ${{ secrets.DOCKER_TOKEN }}
|
||||
|
||||
- name: Build
|
||||
if:
|
||||
${{ steps.baseline.outputs.force_recent == 'true' ||
|
||||
steps.recent_changes.outputs.repo == 'true' }}
|
||||
if: ${{ steps.recent.outputs.has_recent == 'true' }}
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
@@ -109,9 +87,7 @@ jobs:
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
- name: Install goss
|
||||
if:
|
||||
${{ steps.baseline.outputs.force_recent == 'true' ||
|
||||
steps.recent_changes.outputs.repo == 'true' }}
|
||||
if: ${{ steps.recent.outputs.has_recent == 'true' }}
|
||||
env:
|
||||
GOSS_DOWNLOAD: 'https://github.com/goss-org/goss/releases/download'
|
||||
GOSS_VERSION: 'v0.4.8'
|
||||
@@ -120,9 +96,7 @@ jobs:
|
||||
chmod +rx /usr/local/bin/goss
|
||||
|
||||
- name: Run smoke tests
|
||||
if:
|
||||
${{ steps.baseline.outputs.force_recent == 'true' ||
|
||||
steps.recent_changes.outputs.repo == 'true' }}
|
||||
if: ${{ steps.recent.outputs.has_recent == 'true' }}
|
||||
working-directory: tests/smoke
|
||||
timeout-minutes: 2
|
||||
run: |
|
||||
@@ -138,9 +112,7 @@ jobs:
|
||||
docker rm --force smoke
|
||||
|
||||
- name: Push
|
||||
if:
|
||||
${{ steps.baseline.outputs.force_recent == 'true' ||
|
||||
steps.recent_changes.outputs.repo == 'true' }}
|
||||
if: ${{ steps.recent.outputs.has_recent == 'true' }}
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
|
||||
Reference in new issue
Block a user