Skip to content

Commit

Permalink
create docker releases
Browse files Browse the repository at this point in the history
  • Loading branch information
MayNiklas committed Oct 11, 2022
1 parent e5957e0 commit e297cc7
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/docker-image-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: build and push docker image (release)
on:
push:
# run only against tags
tags:
- "*"

jobs:
build-docker-release:
strategy:
matrix:
arch: [x86_64]

runs-on: ubuntu-latest
steps:
- name: setup-docker
uses: docker-practice/actions-setup-docker@master

- name: Install nix
uses: cachix/install-nix-action@v12
with:
nix_path: nixpkgs=channel:nixos-unstable
install_url: https://github.com/numtide/nix-unstable-installer/releases/download/nix-2.12.0pre20221005_ac0fb38/install
# Configure Nix to enable flakes
extra_nix_config: |
experimental-features = nix-command flakes
- name: login to docker hub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin

- name: Checkout
uses: actions/checkout@v2
with:
# Nix Flakes doesn't work on shallow clones
fetch-depth: 0

- name: build docker image
run: |
nix build .#packages.${{ matrix.arch }}-linux.docker-image
docker load < result
- name: execute docker image
run: |
docker run --rm mayniki/shelly-exporter:latest shelly-exporter -h
- name: Set output
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}

- name: push docker image
run: |
docker tag mayniki/shelly-exporter:latest mayniki/shelly-exporter:${{ matrix.arch }}-${{ steps.vars.outputs.tag }}
docker push mayniki/shelly-exporter:${{ matrix.arch }}-${{ steps.vars.outputs.tag }}
manifest-create:
needs: [build-docker-release]
runs-on: ubuntu-latest
steps:
- name: setup-docker
uses: docker-practice/actions-setup-docker@master

- name: login to docker hub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin

- name: Set output
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}

- name: create manifest
run: |
docker manifest create \
mayniki/shelly-exporter:${{ steps.vars.outputs.tag }} \
--amend mayniki/shelly-exporter:x86_64-${{ steps.vars.outputs.tag }}
- name: push manifest
run: |
docker manifest push mayniki/shelly-exporter:${{ steps.vars.outputs.tag }}

0 comments on commit e297cc7

Please sign in to comment.