Skip to content

Commit

Permalink
github: ci: Add extension deployment
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick José Pereira <[email protected]>
  • Loading branch information
patrickelectric authored and rafaellehmkuhl committed Jan 29, 2023
1 parent be6ae70 commit e7a956f
Showing 1 changed file with 70 additions and 1 deletion.
71 changes: 70 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,73 @@ jobs:
with:
name: cockpit-${{ matrix.suffix }}
path: dist/cockpit*.${{ matrix.extension }}
if-no-files-found: error
if-no-files-found: error

deploy-blueos-extension:
needs: test
runs-on: ubuntu-latest
env:
PLATFORMS: "linux/arm/v7,linux/arm64/v8,linux/amd64"
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}

steps:
- name: Login to Docker Hub
if: success() && github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Checkout
uses: actions/checkout@v2

- name: Prepare
id: prepare
run: |
# Deploy image with the name of the branch, if the build is a git tag, replace tag with the tag name.
# If git tag matches semver, append latest tag to the push.
DOCKER_IMAGE=${DOCKER_USERNAME:-bluerobotics}/cockpit
VERSION=${GITHUB_REF##*/}
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
fi
TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS --tag ${DOCKER_IMAGE}:latest"
fi
echo ::set-output name=docker_image::${DOCKER_IMAGE}
echo ::set-output name=version::${VERSION}
echo ::set-output name=buildx_args:: \
${TAGS} \
--file Dockerfile .
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
version: latest

- name: Docker Buildx (build)
run: |
docker buildx build \
--output "type=image,push=false" \
--platform $PLATFORMS \
${{ steps.prepare.outputs.buildx_args }}
- name: Docker Buildx (push)
if: success() && github.event_name != 'pull_request'
run: |
docker buildx build \
--output "type=image,push=true" \
--platform $PLATFORMS \
${{ steps.prepare.outputs.buildx_args }}
- name: Inspect image
if: always() && github.event_name != 'pull_request'
run: |
docker buildx imagetools \
inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}

0 comments on commit e7a956f

Please sign in to comment.