|
1 | 1 | name: Publish Docker image |
| 2 | + |
2 | 3 | on: |
3 | | - release: |
4 | | - types: [published] |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - '**' |
| 7 | + tags: |
| 8 | + - 'v*.*.*' |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - 'master' |
| 12 | + |
5 | 13 | jobs: |
6 | 14 | push_to_registry: |
7 | 15 | name: Push Docker image to GitHub Packages |
8 | 16 | runs-on: ubuntu-latest |
9 | | - permissions: |
10 | | - packages: write |
11 | | - contents: read |
12 | 17 | steps: |
13 | | - - name: Check out the repo |
| 18 | + - name: Checkout |
14 | 19 | 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 |
17 | 24 | 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 }} |
19 | 54 | 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