Skip to content

Commit a546847

Browse files
Updated workflow config
1 parent 70e7bac commit a546847

File tree

1 file changed

+52
-12
lines changed

1 file changed

+52
-12
lines changed

.github/workflows/publish.yml

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,62 @@
11
name: Publish Docker image
2+
23
on:
3-
release:
4-
types: [published]
4+
push:
5+
branches:
6+
- '**'
7+
tags:
8+
- 'v*.*.*'
9+
pull_request:
10+
branches:
11+
- 'master'
12+
513
jobs:
614
push_to_registry:
715
name: Push Docker image to GitHub Packages
816
runs-on: ubuntu-latest
9-
permissions:
10-
packages: write
11-
contents: read
1217
steps:
13-
- name: Check out the repo
18+
- name: Checkout
1419
uses: actions/checkout@v2
15-
- name: Push to GitHub Packages
16-
uses: docker/build-push-action@v1
20+
21+
- name: Docker meta
22+
id: meta
23+
uses: crazy-max/ghaction-docker-meta@v2
1724
with:
18-
username: ${{ github.actor }}
25+
images: ghcr.io/MarcusWichelmann/solaredge-exporter
26+
tags: |
27+
type=schedule
28+
type=ref,event=branch
29+
type=ref,event=pr
30+
type=semver,pattern={{version}}
31+
type=semver,pattern={{major}}.{{minor}}
32+
type=semver,pattern={{major}}
33+
type=sha
34+
35+
- name: Set up QEMU
36+
uses: docker/setup-qemu-action@v1
37+
38+
- name: Set up Docker Buildx
39+
uses: docker/setup-buildx-action@v1
40+
41+
# - name: Login to DockerHub
42+
# if: github.event_name != 'pull_request'
43+
# uses: docker/login-action@v1
44+
# with:
45+
# username: ${{ secrets.DOCKERHUB_USERNAME }}
46+
# password: ${{ secrets.DOCKERHUB_TOKEN }}
47+
48+
- name: Login to GHCR
49+
if: github.event_name != 'pull_request'
50+
uses: docker/login-action@v1
51+
with:
52+
registry: ghcr.io
53+
username: ${{ github.repository_owner }}
1954
password: ${{ secrets.GITHUB_TOKEN }}
20-
registry: docker.pkg.github.com
21-
repository: MarcusWichelmann/SolarEdgeExporter/solaredge-exporter
22-
tag_with_ref: true
55+
56+
- name: Build and push
57+
uses: docker/build-push-action@v2
58+
with:
59+
context: .
60+
push: ${{ github.event_name != 'pull_request' }}
61+
tags: ${{ steps.meta.outputs.tags }}
62+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)