Skip to content

Commit 9ff5d03

Browse files
Merge 241-release-pipeline-does-not-depend-on-tests branch from fork (#256)
I started developing into a fork of this repo but tests don't pass due to how the example repo is set up. Because of this I need to merge my changes into a branch on the real repo.
2 parents 002a1c5 + 78aa8bd commit 9ff5d03

File tree

8 files changed

+102
-42
lines changed

8 files changed

+102
-42
lines changed

.github/workflows/_container.yml

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,9 @@ jobs:
3636

3737
- name: Test cli works in cached runtime image
3838
run: docker run --rm tag_for_testing --version
39-
40-
- name: Create tags for publishing image
41-
id: meta
42-
uses: docker/metadata-action@v5
39+
40+
- name: Upload container as artifact
41+
uses: actions/upload-artifact@v4
4342
with:
44-
images: ghcr.io/${{ github.repository }}
45-
tags: |
46-
type=ref,event=tag
47-
type=raw,value=latest
48-
49-
- name: Push cached image to container registry
50-
if: github.ref_type == 'tag'
51-
uses: docker/build-push-action@v6
52-
env:
53-
DOCKER_BUILD_RECORD_UPLOAD: false
54-
# This does not build the image again, it will find the image in the
55-
# Docker cache and publish it
56-
with:
57-
context: .
58-
push: true
59-
tags: ${{ steps.meta.outputs.tags }}
60-
labels: ${{ steps.meta.outputs.labels }}
43+
name: container
44+
path: container

.github/workflows/_docs.yml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,3 @@ jobs:
3333
with:
3434
name: docs
3535
path: build
36-
37-
- name: Sanitize ref name for docs version
38-
run: echo "DOCS_VERSION=${GITHUB_REF_NAME//[^A-Za-z0-9._-]/_}" >> $GITHUB_ENV
39-
40-
- name: Move to versioned directory
41-
run: mv build/html .github/pages/$DOCS_VERSION
42-
43-
- name: Write switcher.json
44-
run: python .github/pages/make_switcher.py --add $DOCS_VERSION ${{ github.repository }} .github/pages/switcher.json
45-
46-
- name: Publish Docs to gh-pages
47-
if: github.ref_type == 'tag' || github.ref_name == 'main'
48-
# We pin to the SHA, not the tag, for security reasons.
49-
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
50-
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
51-
with:
52-
github_token: ${{ secrets.GITHUB_TOKEN }}
53-
publish_dir: .github/pages
54-
keep_files: true
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
on:
2+
workflow_call:
3+
4+
jobs:
5+
push:
6+
runs-on: ubuntu-latest
7+
8+
steps:
9+
- name: Download container artifact
10+
uses: actions/download-artifact@v4
11+
with:
12+
name: container
13+
path: container
14+
15+
- name: Create tags for publishing image
16+
id: meta
17+
uses: docker/metadata-action@v5
18+
with:
19+
images: ghcr.io/${{ github.repository }}
20+
tags: |
21+
type=ref,event=tag
22+
type=raw,value=latest
23+
24+
- name: Push cached image to container registry
25+
if: github.ref_type == 'tag'
26+
uses: docker/build-push-action@v6
27+
env:
28+
DOCKER_BUILD_RECORD_UPLOAD: false
29+
# This does not build the image again, it will find the image in the
30+
# Docker cache and publish it
31+
with:
32+
context: .
33+
push: true
34+
tags: ${{ steps.meta.outputs.tags }}
35+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/_push_docs.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
on:
2+
workflow_call:
3+
4+
jobs:
5+
build:
6+
runs-on: ubuntu-latest
7+
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v4
11+
with:
12+
# Need this to get version number from last tag
13+
fetch-depth: 0
14+
15+
- name: Download built docs artifact
16+
uses: actions/download-artifact@v4
17+
with:
18+
name: docs
19+
path: build
20+
21+
- name: Sanitize ref name for docs version
22+
run: echo "DOCS_VERSION=${GITHUB_REF_NAME//[^A-Za-z-1-9._-]/_}" >> $GITHUB_ENV
23+
24+
- name: Move to versioned directory
25+
run: mv build/html .github/pages/$DOCS_VERSION
26+
27+
- name: Write switcher.json
28+
run: python .github/pages/make_switcher.py --add $DOCS_VERSION ${{ github.repository }} .github/pages/switcher.json
29+
30+
- name: Publish Docs to gh-pages
31+
if: github.ref_type == 'tag' || github.ref_name == 'main'
32+
# We pin to the SHA, not the tag, for security reasons.
33+
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
34+
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
35+
with:
36+
github_token: ${{ secrets.GITHUB_TOKEN }}
37+
publish_dir: .github/pages
38+
keep_files: true

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ jobs:
3232
permissions:
3333
contents: write
3434

35+
push_docs:
36+
needs: docs
37+
uses: ./.github/workflows/_push_docs.yml
38+
permissions:
39+
contents: write
40+
3541
example:
3642
needs: test
3743
if: github.ref_name == 'main'

template/{% if git_platform=="github.com" %}.github{% endif %}/workflows/ci.yml.jinja

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,25 @@ jobs:
4141
permissions:
4242
contents: read
4343
packages: write
44+
45+
push_container:
46+
if: github.ref_type == 'tag'
47+
needs: [container, test]
48+
uses: ./.github/workflows/_push_container.yml
49+
permissions:
50+
contents: read
51+
packages: write
4452
{% endif %}{% if sphinx %}
4553
docs:
4654
needs: check
4755
if: needs.check.outputs.branch-pr == ''
4856
uses: ./.github/workflows/_docs.yml
57+
58+
push_docs:
59+
needs: docs
60+
uses: ./.github/workflows/_push_docs.yml
61+
permissions:
62+
contents: write
4963
{% endif %}
5064
dist:
5165
needs: check
@@ -54,14 +68,14 @@ jobs:
5468
{% if pypi %}
5569
pypi:
5670
if: github.ref_type == 'tag'
57-
needs: dist
71+
needs: [dist, test]
5872
uses: ./.github/workflows/_pypi.yml
5973
permissions:
6074
id-token: write
6175
{% endif %}
6276
release:
6377
if: github.ref_type == 'tag'
64-
needs: [dist{% if sphinx %}, docs{% endif %}]
78+
needs: [dist, test{% if sphinx %}, docs{% endif %}]
6579
uses: ./.github/workflows/_release.yml
6680
permissions:
6781
contents: write
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../.github/workflows/_push_container.yml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../.github/workflows/_push_docs.yml

0 commit comments

Comments
 (0)