fix: build workflow variables
This commit is contained in:
@@ -7,22 +7,53 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
DEFAULT_BRANCH: main
|
||||||
|
REGISTRY_ORG: allucanget
|
||||||
|
REGISTRY_IMAGE_NAME: calminer
|
||||||
|
REGISTRY_URL: ${{ secrets.REGISTRY_URL }}
|
||||||
|
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Login to Gitea Registry
|
- name: Collect workflow metadata
|
||||||
|
id: meta
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
ref_name="${GITHUB_REF_NAME:-${GITHUB_REF##*/}}"
|
||||||
|
event_name="${GITHUB_EVENT_NAME:-}"
|
||||||
|
sha="${GITHUB_SHA:-}"
|
||||||
|
|
||||||
|
if [ "$ref_name" = "${DEFAULT_BRANCH:-main}" ]; then
|
||||||
|
echo "on_default=true" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "on_default=false" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "ref_name=$ref_name" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "event_name=$event_name" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "sha=$sha" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Set up QEMU and Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Log in to Gitea registry
|
||||||
|
if: ${{ steps.meta.outputs.on_default == 'true' }}
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
|
continue-on-error: true
|
||||||
with:
|
with:
|
||||||
registry: ${{ secrets.REGISTRY_URL }}
|
registry: ${{ env.REGISTRY_URL }}
|
||||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
username: ${{ env.REGISTRY_USERNAME }}
|
||||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
password: ${{ env.REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
file: Dockerfile
|
||||||
tags: ${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USERNAME }}/calminer:latest
|
push: ${{ steps.meta.outputs.on_default == 'true' && steps.meta.outputs.event_name != 'pull_request' && (env.REGISTRY_URL != '' && env.REGISTRY_USERNAME != '' && env.REGISTRY_PASSWORD != '') }}
|
||||||
cache-from: type=gha
|
tags: |
|
||||||
cache-to: type=gha,mode=max
|
${{ env.REGISTRY_URL }}/${{ env.REGISTRY_ORG }}/${{ env.REGISTRY_IMAGE_NAME }}:latest
|
||||||
|
${{ env.REGISTRY_URL }}/${{ env.REGISTRY_ORG }}/${{ env.REGISTRY_IMAGE_NAME }}:${{ steps.meta.outputs.sha }}
|
||||||
|
|||||||
@@ -94,7 +94,8 @@ def page(browser: Browser, live_server: str) -> Generator[Page, None, None]:
|
|||||||
def _prepare_database_environment(env: Dict[str, str]) -> Dict[str, str]:
|
def _prepare_database_environment(env: Dict[str, str]) -> Dict[str, str]:
|
||||||
"""Ensure granular database env vars are available for the app under test."""
|
"""Ensure granular database env vars are available for the app under test."""
|
||||||
|
|
||||||
required = ("DATABASE_HOST", "DATABASE_USER", "DATABASE_NAME")
|
required = ("DATABASE_HOST", "DATABASE_USER",
|
||||||
|
"DATABASE_NAME", "DATABASE_PASSWORD")
|
||||||
if all(env.get(key) for key in required):
|
if all(env.get(key) for key in required):
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user