File tree Expand file tree Collapse file tree 8 files changed +102
-42
lines changed
template/{% if git_platform=="github.com" %}.github{% endif %}/workflows Expand file tree Collapse file tree 8 files changed +102
-42
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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 }}
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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'
Original file line number Diff line number Diff 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 number Diff line number Diff line change 1+ ../../../.github/workflows/_push_container.yml
Original file line number Diff line number Diff line change 1+ ../../../.github/workflows/_push_docs.yml
You can’t perform that action at this time.
0 commit comments