-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added offscreen cicd & local cache #353
Changes from 6 commits
92e2f9f
b976793
f37d3b0
5195dd2
8f91d1a
f26a56f
bcbb6e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,15 @@ jobs: | |
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create cache directory | ||
run: | | ||
mkdir -p ./.buildx-cache/cache | ||
mkdir ./.buildx-cache/cache-new | ||
mkdir ./.buildx-cache/cache/test | ||
mkdir ./.buildx-cache/cache/latest | ||
mkdir ./.buildx-cache/cache-new/test | ||
mkdir ./.buildx-cache/cache-new/latest | ||
|
||
- name: Test build | ||
if: github.event_name == 'pull_request' | ||
uses: docker/build-push-action@v3 | ||
|
@@ -50,8 +59,8 @@ jobs: | |
file: ./build/docker/agent/Dockerfile | ||
load: true | ||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}:test | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
cache-from: type=local,src=./.buildx-cache/cache/test/ | ||
cache-to: type=local,dest=./.buildx-cache/cache-new/test/,mode=max | ||
build-args: | | ||
USERNAME=paf | ||
USER_UID=1000 | ||
|
@@ -67,8 +76,8 @@ jobs: | |
push: true | ||
# tag 'latest' and version on push to main, otherwise use the commit hash | ||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
cache-from: type=local,src=./.buildx-cache/cache/latest/ | ||
cache-to: type=local,dest=./.buildx-cache/cache-new/latest/,mode=max | ||
build-args: | | ||
USERNAME=paf | ||
USER_UID=1000 | ||
|
@@ -85,4 +94,10 @@ jobs: | |
uses: actions/upload-artifact@v4 | ||
with: | ||
name: pr_id | ||
path: pr/ | ||
path: pr/ | ||
Comment on lines
+97
to
+98
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add PR ID validation. The PR ID saving process should validate the input to prevent empty or invalid values from being stored. - name: Save PR ID
env:
PR_ID: ${{ github.event.number }}
run: |
+ if [ -z "$PR_ID" ]; then
+ echo "Error: PR_ID is empty"
+ exit 1
+ fi
mkdir -p ./pr
echo $PR_ID > ./pr/pr_id
|
||
retention-days: 1 | ||
|
||
- name: Clean up cache | ||
run: | | ||
rm -rf ./.buildx-cache | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix cache cleanup paths and add error handling. The cache cleanup step has several issues:
Apply this fix: - name: Clean up cache
run: |
+ set -e # Exit on any error
rm -rf ./.buildx-cache
- mv ./.buildx-cache-new /tmp/.buildx-cache
+ mv ./.buildx-cache/cache-new /tmp/.buildx-cache
+
🧰 Tools🪛 yamllint
|
||
mv ./.buildx-cache-new /tmp/.buildx-cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add error handling and cleanup to cache directory creation.
The directory creation script should handle potential failures and clean up existing directories to prevent issues with stale cache data.
📝 Committable suggestion