-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |