Skip to content

Commit

Permalink
wip: push load
Browse files Browse the repository at this point in the history
  • Loading branch information
snaselj committed Oct 12, 2023
1 parent cd5b7ff commit 3a63a13
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
21 changes: 16 additions & 5 deletions .github/actions/build-push/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ inputs:
username:
description: "GitHub Username"
required: true
push:
description: "Push Docker Image"
required: false
default: ""
load:
description: "Load Docker Image"
required: false
default: ""
outputs:
image:
description: "Docker Image Reference"
Expand All @@ -41,26 +49,29 @@ runs:
id: "buildx"
uses: "docker/setup-buildx-action@v3"
- name: "Build"
if: |
inputs.push == 'true'
uses: "docker/build-push-action@v5"
with:
push: true
context: "./"
file: "./development/Dockerfile"
load: true
tags: "${{ inputs.image-prefix }}:${{ inputs.image-tag }}"
cache-from: "type=gha,scope=${{ inputs.image-tag }}"
cache-to: "type=local,dest=/tmp/.buildx-cache"
cache-to: "type=gha,scope=${{ inputs.image-tag }}"
build-args: |
NAUTOBOT_VER=${{ inputs.nautobot-version }}
PYTHON_VER=${{ inputs.python-version }}
- name: "Build"
if: |
inputs.load == 'true'
uses: "docker/build-push-action@v5"
with:
load: true
context: "./"
file: "./development/Dockerfile"
push: true
tags: "${{ inputs.image-prefix }}:${{ inputs.image-tag }}"
cache-from: "type=local,src=/tmp/.buildx-cache"
cache-to: "type=gha,scope=${{ inputs.image-tag }}"
cache-from: "type=gha,scope=${{ inputs.image-tag }}"
build-args: |
NAUTOBOT_VER=${{ inputs.nautobot-version }}
PYTHON_VER=${{ inputs.python-version }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/single-test-simple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ jobs:
add-image-reference: "${{ steps.config.outputs.image }}"
image-prefix: "ghcr.io/${{ github.repository }}/nautobot-dev"
image-tag: "pr-${{ github.event.pull_request.number }}-${{ env.NAUTOBOT_VER }}-py${{ env.PYTHON_VER }}"
load: true
nautobot-version: "${{ env.NAUTOBOT_VER }}"
password: ${{ secrets.GH_NAUTOBOT_BOT_TOKEN }}
push: true
python-version: "${{ env.PYTHON_VER }}"
username: ${{ github.actor }}
- name: "Run Linters"
Expand Down
12 changes: 5 additions & 7 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,27 +703,25 @@ def calc_dbdump_cache_key(context):
- Nautobot version.
- Database server Docker image reference.
"""
migrations_dir = Path('nautobot_firewall_modesl/migrations')
migrations_dir = Path("nautobot_firewall_modesl/migrations")
hasher = sha256()

if migrations_dir.is_dir():
for file in sorted(migrations_dir.rglob('*.py')):
for file in sorted(migrations_dir.rglob("*.py")):
if file.is_file():
with file.open('r') as f:
with file.open("r") as f:
hasher.update(f.read().encode())

hasher.update(context.nautobot_firewall_models.nautobot_ver.encode())


with context.cd(context.nautobot_firewall_models.compose_dir):
db_image_ref = context.run(
'docker compose convert --format json | jq -r .services.db.image',
"docker compose convert --format json | jq -r .services.db.image",
hide=True,
env={
"COMPOSE_FILE": ":".join(context.nautobot_firewall_models.compose_files),
}
},
)
hasher.update(db_image_ref.stdout.strip().encode())


print(hasher.hexdigest())

0 comments on commit 3a63a13

Please sign in to comment.