Skip to content

Commit

Permalink
Merge pull request #3 from SMI/rkm
Browse files Browse the repository at this point in the history
Only rebuild containers if files changed
  • Loading branch information
rkm authored Mar 26, 2024
2 parents 42d7d6d + 776195f commit a68a90c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,19 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: skip if unchanged
run: |
set -euxo pipefail
SKIP=0
if ! git diff --name-only HEAD^ | grep "software/${{ matrix.package }}" | grep -v README > /dev/null
then
SKIP=1
fi
echo "SKIP=$SKIP" >> "$GITHUB_ENV"
- name: free disk space
if: env.SKIP == '0'
run: |
set -euxo pipefail
df -h
Expand All @@ -33,6 +45,7 @@ jobs:
sudo docker image prune --all --force
df -h
- name: build image
if: env.SKIP == '0'
run: |
set -euxo pipefail
package="${{ matrix.package }}"
Expand All @@ -44,7 +57,7 @@ jobs:
echo "img=$img" >> "$GITHUB_ENV"
echo "tag=$tag" >> "$GITHUB_ENV"
- name: push image
if: github.ref == 'refs/heads/main'
if: env.SKIP == '0' && github.ref == 'refs/heads/main'
run: |
set -euxo pipefail
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
Expand Down

0 comments on commit a68a90c

Please sign in to comment.