Run smoke tests before Docker builds

https://github.com/pypa/gh-action-pypi-publish/pull/230#discussion_r1787027821
This commit is contained in:
Brendon Smith 2024-10-04 18:23:49 -04:00
parent da554410b0
commit 36965cb24a
No known key found for this signature in database
3 changed files with 8 additions and 11 deletions

View file

@ -14,8 +14,13 @@ on: # yamllint disable-line rule:truthy
type: string type: string
jobs: jobs:
smoke-test:
uses: ./.github/workflows/reusable-smoke-test.yml
build-and-push: build-and-push:
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs:
- smoke-test
timeout-minutes: 10 timeout-minutes: 10
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@ -39,17 +44,11 @@ jobs:
env: env:
DOCKER_TAG: ${{ inputs.tag || github.ref_name }} DOCKER_TAG: ${{ inputs.tag || github.ref_name }}
- name: Log in to GHCR - name: Log in to GHCR
if: github.event_name != 'pull_request'
run: >- run: >-
echo ${{ secrets.GITHUB_TOKEN }} | echo ${{ secrets.GITHUB_TOKEN }} |
docker login ghcr.io -u $GITHUB_ACTOR --password-stdin docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
- name: Push Docker image to GHCR - name: Push Docker image to GHCR
if: github.event_name != 'pull_request'
run: | run: |
docker push $IMAGE docker push $IMAGE
docker push $IMAGE_MAJOR docker push $IMAGE_MAJOR
docker push $IMAGE_MAJOR_MINOR docker push $IMAGE_MAJOR_MINOR
smoke-test:
needs:
- build-and-push
uses: ./.github/workflows/reusable-smoke-test.yml

View file

@ -141,7 +141,6 @@ runs:
# Create Docker container action # Create Docker container action
python create-docker-action.py python create-docker-action.py
env: env:
EVENT: ${{ github.event_name }}
REF: ${{ steps.set-repo-and-ref.outputs.ref }} REF: ${{ steps.set-repo-and-ref.outputs.ref }}
REPO: ${{ steps.set-repo-and-ref.outputs.repo }} REPO: ${{ steps.set-repo-and-ref.outputs.repo }}
REPO_ID: ${{ steps.set-repo-and-ref.outputs.repo-id }} REPO_ID: ${{ steps.set-repo-and-ref.outputs.repo-id }}

View file

@ -5,21 +5,20 @@ import pathlib
DESCRIPTION = 'description' DESCRIPTION = 'description'
REQUIRED = 'required' REQUIRED = 'required'
EVENT = os.environ['EVENT']
REF = os.environ['REF'] REF = os.environ['REF']
REPO = os.environ['REPO'] REPO = os.environ['REPO']
REPO_ID = os.environ['REPO_ID'] REPO_ID = os.environ['REPO_ID']
REPO_ID_GH_ACTION = '178055147' REPO_ID_GH_ACTION = '178055147'
def set_image(event: str, ref: str, repo: str, repo_id: str) -> str: def set_image(ref: str, repo: str, repo_id: str) -> str:
if event == 'pull_request' and repo_id == REPO_ID_GH_ACTION: if repo_id == REPO_ID_GH_ACTION:
return '../../../Dockerfile' return '../../../Dockerfile'
docker_ref = ref.replace('/', '-') docker_ref = ref.replace('/', '-')
return f'docker://ghcr.io/{repo}:{docker_ref}' return f'docker://ghcr.io/{repo}:{docker_ref}'
image = set_image(EVENT, REF, REPO, REPO_ID) image = set_image(REF, REPO, REPO_ID)
action = { action = {
'name': '🏃', 'name': '🏃',