Skip to content

Commit

Permalink
[actions] upload docker image tar to artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
lmnotran committed Jun 19, 2024
1 parent 3b7918b commit 3402bd9
Showing 1 changed file with 53 additions and 25 deletions.
78 changes: 53 additions & 25 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ env:
TEST_TAG: siliconlabsinc/ot-efr32-dev:test
SHA_TAG: siliconlabsinc/ot-efr32-dev:${{ github.sha }}
LATEST_TAG: siliconlabsinc/ot-efr32-dev:latest
DOCKER_IMAGE_ARTIFACT_NAME: ot-efr32-dev-image-${{ github.sha }}-${{ github.event_name}}
DOCKER_IMAGE_TAR: ot-efr32-dev-image-${{ github.sha }}.tar

on:
push:
Expand Down Expand Up @@ -77,8 +79,10 @@ jobs:
linux/amd64
tags: |
${{ env.TEST_TAG }}
${{ env.SHA_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=oci,dest=${{ env.DOCKER_IMAGE_TAR}}

- name: Container image sanity checks
run: |
Expand Down Expand Up @@ -106,30 +110,54 @@ jobs:
run: |
docker run -v ${{ github.workspace }}:/ot-efr32/ --user $(id -u) --rm ${{ env.TEST_TAG }} script/build --skip-silabs-apps brd4151a
- name: Login to DockerHub
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
if: |
success() &&
github.repository == 'SiliconLabs/ot-efr32' &&
github.event_name != 'pull_request' &&
github.ref == 'refs/heads/main'
- name: Upload docker image
uses: actions/upload-artifact@4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
name: ${{ env.DOCKER_IMAGE_ARTIFACT_NAME }}
path: ${{ env.DOCKER_IMAGE_TAR }}

- name: Build and push
uses: docker/build-push-action@v5
if: |
success() &&
github.repository == 'SiliconLabs/ot-efr32' &&
github.event_name != 'pull_request' &&
github.ref == 'refs/heads/main'
with:
context: .
file: docker/Dockerfile
push: true
tags: |
${{ env.LATEST_TAG }}
${{ env.SHA_TAG }}
platforms:
linux/amd64
publish:
name: Publish to DockerHub
runs-on: ubuntu-22.04
needs: [build]
if: |
github.repository == 'SiliconLabs/ot-efr32' &&
github.event_name != 'pull_request'
steps:
- name: Login to DockerHub
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Download Docker image
uses: actions/download-artifact@v4
with:
name: ${{ env.DOCKER_IMAGE_ARTIFACT_NAME }}

- name: Load Docker image
run: docker load -i ${{ env.DOCKER_IMAGE_TAR }}

- name: Build and push
uses: docker/build-push-action@v5
if: github.ref == 'refs/heads/main'
with:
context: .
file: docker/Dockerfile
push: true
tags: |
${{ env.SHA_TAG }}
platforms:
linux/amd64

- name: Tag `latest` and push
uses: docker/build-push-action@v5
if: github.ref == 'refs/heads/main'
with:
context: .
file: docker/Dockerfile
push: true
tags: |
${{ env.LATEST_TAG }}
platforms:
linux/amd64

0 comments on commit 3402bd9

Please sign in to comment.