Skip to content

Commit

Permalink
Merge pull request #1056 from mountaindude/docker-build
Browse files Browse the repository at this point in the history
Debug Docker build step in GA
  • Loading branch information
mountaindude authored Apr 8, 2024
2 parents a3a3441 + 1582cec commit b14d1f5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
46 changes: 42 additions & 4 deletions .github/workflows/docker-image-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ on:
description: 'Test scenario tags'
required: false
release:
types: [published]
types:
- published

jobs:
build:
Expand Down Expand Up @@ -45,51 +46,73 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'ptarmiganlabs'
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'ptarmiganlabs'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'ptarmiganlabs'
# Login against a Docker registry except on PR
# https://github.com/marketplace/actions/docker-login
# https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context
- name: Login to Docker Hub
uses: docker/login-action@v3
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'ptarmiganlabs'
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# Docker tag has format: refs/tags/v1.2.3
# Docker tag has format: refs/tags/butler-v1.2.3
# We need to extract the tag semver from the full tag
# Store the tag in GITHUB_ENV environment variable
- name: Create clean tag for Docker
run: |
export TAGTMP1=${{ github.ref }}
export TAG=${TAGTMP1##*/}
#export TAGTMP1=${{ github.ref }}
#export TAG=${TAGTMP1##*/}
export TAG=$(echo ${{ github.ref }} | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' | cut -c 2-)
echo "TAG=$TAG" >> $GITHUB_ENV
# Debug
echo "TAGTMP1=$TAGTMP1"
echo "TAG=$TAG"
echo "GITHUB_ENV=$GITHUB_ENV"
# export TAGTMP2=${TAGTMP1##*/}
# export TAG=${TAGTMP2##*-}
# echo "TAG=$TAG" >> $GITHUB_ENV
- name: Dump GitHub context
if: always()
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Dump job context
if: always()
env:
JOB_CONTEXT: ${{ toJSON(job) }}
run: echo "$JOB_CONTEXT"
- name: Dump steps context
if: always()
env:
STEPS_CONTEXT: ${{ toJSON(steps) }}
run: echo "$STEPS_CONTEXT"
- name: Dump runner context
if: always()
env:
RUNNER_CONTEXT: ${{ toJSON(runner) }}
run: echo "$RUNNER_CONTEXT"
- name: Dump strategy context
if: always()
env:
STRATEGY_CONTEXT: ${{ toJSON(strategy) }}
run: echo "$STRATEGY_CONTEXT"
Expand All @@ -99,6 +122,9 @@ jobs:
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'ptarmiganlabs'
with:
# images: ${{ env.IMAGE_NAME }}
images: ${{ github.repository }}
Expand All @@ -110,14 +136,23 @@ jobs:
type=semver,pattern={{major}},value=${{ env.TAG }}
- name: Show Docker tags that will be used
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'ptarmiganlabs'
run: echo '${{ steps.meta.outputs.tags }}'

- name: Show Docker labels that will be used
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'ptarmiganlabs'
run: echo '${{ steps.meta.outputs.labels }}'

- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'ptarmiganlabs'
with:
context: .
platforms: |
Expand All @@ -129,6 +164,9 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}

- name: Image digest
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'ptarmiganlabs'
run: echo ${{ steps.docker_build.outputs.digest }}

# Send MQTT message similar to this:
Expand Down
4 changes: 2 additions & 2 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"last-release-sha": "f6f4424bdc795a4f0182eb01b387bf20029260e6",
"release-as": "11.1.0",
"last-release-sha": "5eb72501b7a39ebc5abef071a6182082a5f1749f",
"release-as": "11.1.1",
"release-type": "node",
"prerelease": false,
"draft": true,
Expand Down

0 comments on commit b14d1f5

Please sign in to comment.