Skip to content

Commit

Permalink
Run smoke tests before Docker builds
Browse files Browse the repository at this point in the history
  • Loading branch information
br3ndonland committed Nov 4, 2024
1 parent da55441 commit 36965cb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/build-and-push-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ on: # yamllint disable-line rule:truthy
type: string

jobs:
smoke-test:
uses: ./.github/workflows/reusable-smoke-test.yml
build-and-push:
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
needs:
- smoke-test
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
Expand All @@ -39,17 +44,11 @@ jobs:
env:
DOCKER_TAG: ${{ inputs.tag || github.ref_name }}
- name: Log in to GHCR
if: github.event_name != 'pull_request'
run: >-
echo ${{ secrets.GITHUB_TOKEN }} |
docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
- name: Push Docker image to GHCR
if: github.event_name != 'pull_request'
run: |
docker push $IMAGE
docker push $IMAGE_MAJOR
docker push $IMAGE_MAJOR_MINOR
smoke-test:
needs:
- build-and-push
uses: ./.github/workflows/reusable-smoke-test.yml
1 change: 0 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ runs:
# Create Docker container action
python create-docker-action.py
env:
EVENT: ${{ github.event_name }}
REF: ${{ steps.set-repo-and-ref.outputs.ref }}
REPO: ${{ steps.set-repo-and-ref.outputs.repo }}
REPO_ID: ${{ steps.set-repo-and-ref.outputs.repo-id }}
Expand Down
7 changes: 3 additions & 4 deletions create-docker-action.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@
DESCRIPTION = 'description'
REQUIRED = 'required'

EVENT = os.environ['EVENT']
REF = os.environ['REF']
REPO = os.environ['REPO']
REPO_ID = os.environ['REPO_ID']
REPO_ID_GH_ACTION = '178055147'


def set_image(event: str, ref: str, repo: str, repo_id: str) -> str:
if event == 'pull_request' and repo_id == REPO_ID_GH_ACTION:
def set_image(ref: str, repo: str, repo_id: str) -> str:
if repo_id == REPO_ID_GH_ACTION:
return '../../../Dockerfile'
docker_ref = ref.replace('/', '-')
return f'docker://ghcr.io/{repo}:{docker_ref}'


image = set_image(EVENT, REF, REPO, REPO_ID)
image = set_image(REF, REPO, REPO_ID)

action = {
'name': '🏃',
Expand Down

0 comments on commit 36965cb

Please sign in to comment.