Skip to content

Commit 4f1c416

Browse files
authored
ci: use gha cache and fix release-please triggers (#966)
This pull request updates the Docker build and caching strategy in the CI and release GitHub Actions workflows. The main improvements are switching to GitHub Actions (GHA) cache storage for Docker layers, simplifying the build and test steps, and ensuring certain jobs are skipped for release-please branches. **CI Workflow improvements:** * Switched Docker image caching from manual artifact upload/download to using `docker/build-push-action` with GHA cache storage, streamlining the build and test process (`.github/workflows/ci.yml`). [[1]](diffhunk://#diff-b803fcb7f17ed9235f1e5cb1fcd2f5d3b2838429d4368ae4c57ce4436577f03fR129-R146) [[2]](diffhunk://#diff-b803fcb7f17ed9235f1e5cb1fcd2f5d3b2838429d4368ae4c57ce4436577f03fL161-R168) * Added job conditions to skip Docker build and test steps for release-please branches in pull requests, reducing unnecessary CI runs (`.github/workflows/ci.yml`). [[1]](diffhunk://#diff-b803fcb7f17ed9235f1e5cb1fcd2f5d3b2838429d4368ae4c57ce4436577f03fR129-R146) [[2]](diffhunk://#diff-b803fcb7f17ed9235f1e5cb1fcd2f5d3b2838429d4368ae4c57ce4436577f03fL161-R168) **Release Workflow improvements:** * Removed local Docker cache management and replaced with GHA cache for Docker buildx, simplifying cache handling and improving cache sharing across runners (`.github/workflows/release.yml`). [[1]](diffhunk://#diff-87db21a973eed4fef5f32b267aa60fcee5cbdf03c67fafdc2a9b553bb0b15f34L157-L164) [[2]](diffhunk://#diff-87db21a973eed4fef5f32b267aa60fcee5cbdf03c67fafdc2a9b553bb0b15f34L177-R170) [[3]](diffhunk://#diff-87db21a973eed4fef5f32b267aa60fcee5cbdf03c67fafdc2a9b553bb0b15f34L191-L195) These changes make the workflows more efficient, easier to maintain, and better leverage GitHub Actions built-in caching for Docker images.
1 parent 87f1aeb commit 4f1c416

2 files changed

Lines changed: 19 additions & 33 deletions

File tree

.github/workflows/ci.yml

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -126,26 +126,24 @@ jobs:
126126
- ruby
127127
- openapi
128128
- frontend
129+
if: github.event_name != 'pull_request' || !startsWith(github.head_ref, 'release-please--')
129130
runs-on: ubuntu-latest
130131
steps:
131132
- uses: actions/checkout@v6
132-
133+
- uses: docker/setup-buildx-action@v4
133134
- name: Build Docker smoke image
134-
run: docker build -t html2rss/web -f Dockerfile .
135-
136-
- name: Export Docker smoke image
137-
run: docker save html2rss/web -o /tmp/html2rss-web-smoke-image.tar
138-
139-
- name: Upload Docker smoke image
140-
uses: actions/upload-artifact@v7
135+
uses: docker/build-push-action@v7
141136
with:
142-
name: docker-smoke-image
143-
path: /tmp/html2rss-web-smoke-image.tar
144-
retention-days: 1
137+
context: .
138+
load: true
139+
tags: html2rss/web
140+
cache-from: type=gha
141+
cache-to: type=gha,mode=max
145142

146143
docker-test:
147144
needs:
148145
- docker-build-smoke-image
146+
if: github.event_name != 'pull_request' || !startsWith(github.head_ref, 'release-please--')
149147
runs-on: ubuntu-latest
150148
strategy:
151149
fail-fast: false
@@ -158,14 +156,15 @@ jobs:
158156
with:
159157
bundler-cache: true
160158

161-
- name: Download Docker smoke image
162-
uses: actions/download-artifact@v8
163-
with:
164-
name: docker-smoke-image
165-
path: /tmp
159+
- uses: docker/setup-buildx-action@v4
166160

167-
- name: Load Docker smoke image
168-
run: docker load -i /tmp/html2rss-web-smoke-image.tar
161+
- name: Load Docker smoke image from cache
162+
uses: docker/build-push-action@v7
163+
with:
164+
context: .
165+
load: true
166+
tags: html2rss/web
167+
cache-from: type=gha
169168

170169
- name: Run Docker smoke test
171170
env:

.github/workflows/release.yml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,6 @@ jobs:
154154
username: ${{ secrets.DOCKER_USERNAME }}
155155
password: ${{ secrets.DOCKER_PASSWORD }}
156156

157-
- name: Cache Docker layers
158-
uses: actions/cache@v4
159-
with:
160-
path: /tmp/.buildx-cache
161-
key: ${{ runner.os }}-buildx-${{ github.sha }}
162-
restore-keys: |
163-
${{ runner.os }}-buildx-
164-
165157
- name: Build and push Docker image
166158
uses: docker/build-push-action@v7
167159
env:
@@ -174,8 +166,8 @@ jobs:
174166
BUILD_TAG=${{ env.RELEASE_VERSION }}
175167
GIT_SHA=${{ needs.guard.outputs.target_sha }}
176168
platforms: linux/amd64,linux/arm64
177-
cache-from: type=local,src=/tmp/.buildx-cache
178-
cache-to: type=local,dest=/tmp/.buildx-cache-new
169+
cache-from: type=gha
170+
cache-to: type=gha,mode=max
179171
provenance: true
180172
sbom: true
181173
labels: |
@@ -188,11 +180,6 @@ jobs:
188180
org.opencontainers.image.url=https://github.com/${{ github.repository }}/releases/tag/${{ env.RELEASE_TAG }}
189181
org.opencontainers.image.version=${{ env.RELEASE_VERSION }}
190182
191-
- name: Move updated cache into place
192-
run: |
193-
rm -rf /tmp/.buildx-cache
194-
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
195-
196183
- name: Summarize published image tags
197184
run: |
198185
{

0 commit comments

Comments
 (0)