Skip to content

Commit 412ca99

Browse files
author
Sam Harrison
committed
fix: only do a Docker Login if the secrets are available
1 parent 0c7a723 commit 412ca99

File tree

1 file changed

+37
-28
lines changed

1 file changed

+37
-28
lines changed

.github/workflows/test-and-deploy.yml

+37-28
Original file line numberDiff line numberDiff line change
@@ -18,46 +18,55 @@ jobs:
1818
strategy:
1919
matrix:
2020
python-version: [ '2.7', '3.5', '3.6', '3.7', '3.8', '3.9' ]
21+
env:
22+
DOCKER_LOGIN: ${{ secrets.DOCKER_USERNAME && secrets.DOCKER_AUTH_TOKEN }}
2123
steps:
2224
- name: Checkout sendgrid-python
2325
uses: actions/checkout@v2
2426

27+
- name: Login to Docker Hub
28+
if: env.DOCKER_LOGIN
29+
uses: docker/login-action@v1
30+
with:
31+
username: ${{ secrets.DOCKER_USERNAME }}
32+
password: ${{ secrets.DOCKER_AUTH_TOKEN }}
33+
2534
- name: Build & Test
2635
run: make test-docker version=${{ matrix.python-version }}
2736

2837
deploy:
29-
name: Deploy
30-
if: success() && github.ref_type == 'tag'
31-
needs: [ test ]
32-
runs-on: ubuntu-latest
33-
steps:
34-
- name: Checkout sendgrid-python
35-
uses: actions/checkout@v2
38+
name: Deploy
39+
if: success() && github.ref_type == 'tag'
40+
needs: [ test ]
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Checkout sendgrid-python
44+
uses: actions/checkout@v2
3645

37-
- name: Set up Python
38-
uses: actions/setup-python@v2
39-
with:
40-
python-version: '3.6'
46+
- name: Set up Python
47+
uses: actions/setup-python@v2
48+
with:
49+
python-version: '3.6'
4150

42-
- name: Install dependencies
43-
run: |
44-
python -m pip install --upgrade pip
45-
pip install build
46-
pip install wheel
47-
python setup.py sdist bdist_wheel
51+
- name: Install dependencies
52+
run: |
53+
python -m pip install --upgrade pip
54+
pip install build
55+
pip install wheel
56+
python setup.py sdist bdist_wheel
4857
49-
- name: Create GitHub Release
50-
uses: sendgrid/dx-automator/actions/release@main
51-
with:
52-
footer: '**[pypi](https://pypi.org/project/sendgrid/${version})**'
53-
env:
54-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
- name: Create GitHub Release
59+
uses: sendgrid/dx-automator/actions/release@main
60+
with:
61+
footer: '**[pypi](https://pypi.org/project/sendgrid/${version})**'
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5564

56-
- name: Publish package to PyPI
57-
uses: pypa/gh-action-pypi-publish@release/v1
58-
with:
59-
user: __token__
60-
password: ${{ secrets.PYPI_TOKEN }}
65+
- name: Publish package to PyPI
66+
uses: pypa/gh-action-pypi-publish@release/v1
67+
with:
68+
user: __token__
69+
password: ${{ secrets.PYPI_TOKEN }}
6170

6271
notify-on-failure:
6372
name: Slack notify on failure

0 commit comments

Comments
 (0)