11# run test suites
22
3- name : Tests
3+ name : Tests and Deployment
44on :
55 - pull_request
66 - push
@@ -13,9 +13,13 @@ concurrency:
1313 group : " ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}"
1414 cancel-in-progress : true
1515
16+ permissions :
17+ contents : read
18+
1619jobs :
1720 # see: https://github.com/fkirc/skip-duplicate-actions
1821 skip_duplicate :
22+ name : Skip Duplicate Workflows
1923 continue-on-error : true
2024 runs-on : ubuntu-latest
2125 outputs :
3034
3135 # see: https://github.com/actions/setup-python
3236 tests :
37+ name : Test
3338 needs : skip_duplicate
3439 if : ${{ needs.skip_duplicate.outputs.should_skip != 'true' }}
3540 runs-on : ${{ matrix.os }}
@@ -71,14 +76,17 @@ jobs:
7176 allow-failure : false
7277 test-case : test-local
7378 steps :
74- - uses : actions/checkout@v2
79+ - name : Checkout Repository
80+ uses : actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
7581 with :
7682 fetch-depth : " 0"
77- - name : Setup Python
78- uses : actions/setup-python@v5
83+ persist-credentials : false
84+ - name : Set up Python3
7985 if : ${{ matrix.python-version != 'None' }}
86+ uses : actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
8087 with :
8188 python-version : ${{ matrix.python-version }}
89+ cache : ' pip'
8290 - name : Install Dependencies
8391 if : ${{ matrix.python-version != 'None' }}
8492 # install package and dependencies directly,
@@ -97,32 +105,69 @@ jobs:
97105 if : ${{ matrix.python-version == 'None' }}
98106 run : make docker-stop
99107 - name : Upload coverage report
100- uses : codecov/codecov-action@v4.0.1
108+ uses : codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
101109 if : ${{ success() && matrix.test-case == 'coverage' }}
102110 with :
103111 token : ${{ secrets.CODECOV_TOKEN }}
104112 files : ./coverage/coverage.xml
105113 fail_ci_if_error : true
106114 verbose : true
107115
116+ # FIXME: We should split the deployment job into its own workflow. Token-based updates to PyPI are heavily discouraged in favour of Trusted Publishing.
108117 deploy_pypi :
118+ name : Deploy (PyPI)
109119 needs : tests
110120 # Don't match master branch for upload to avoid duplicate error, even if the tag is usually applied on master.
111121 if : ${{ success() && github.event_name == 'push' && contains(github.ref, 'refs/tags') }}
112122 runs-on : ubuntu-latest
113123 steps :
114- - uses : actions/checkout@v2
124+ - name : Checkout Repository
125+ uses : actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
115126 with :
116127 fetch-depth : " 0"
117- - name : Setup Python
118- uses : actions/setup-python@v5
128+ persist-credentials : false
129+
130+ - name : Set up Python3
131+ uses : actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
119132 with :
120133 python-version : " 3.11"
134+
121135 - name : Build Distribution Package
122- run : make develop dist
136+ run : |
137+ make develop dist
138+
123139 - name : Push Package to PyPi
124- uses : pypa/gh-action-pypi-publish@release/v1
140+ uses : pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
125141 with :
126142 user : __token__
127143 password : ${{ secrets.PYPI_API_TOKEN }}
128144 verbose : true # For debugging 'twine upload' if a problem occurs.
145+
146+ deploy_docker :
147+ name : Deploy (DockerHub)
148+ needs : tests
149+ if : ${{ success() && (contains(github.ref, 'refs/tags') || github.ref == 'refs/heads/master') }}
150+ runs-on : ubuntu-latest
151+ steps :
152+ - name : Checkout Repository
153+ uses : actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
154+ with :
155+ fetch-depth : " 0"
156+ persist-credentials : false
157+
158+ - name : Set up Docker Buildx
159+ uses : docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
160+
161+ # FIXME: We should be using a PAT generated specifically for this. docker/build-push-action accepts PATs directly.
162+ - name : Login to DockerHub
163+ uses : docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
164+ with :
165+ username : ${{ secrets.DOCKERHUB_USERNAME }}
166+ password : ${{ secrets.DOCKERHUB_TOKEN }}
167+
168+ - name : Build Docker image
169+ uses : docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
170+ with :
171+ file : " Dockerfile"
172+ push : true
173+ tags : birdhouse/twitcher:latest,birdhouse/twitcher:${{ github.ref_name }}
0 commit comments