| 1 | name: Package |
| 2 | on: |
| 3 | push: |
| 4 | branches: |
| 5 | - master |
| 6 | release: |
| 7 | types: |
| 8 | - published |
| 9 | pull_request: |
| 10 | branches: |
| 11 | - master |
| 12 | jobs: |
| 13 | test: |
| 14 | runs-on: ubuntu-latest |
| 15 | steps: |
| 16 | - name: Checkout |
| 17 | uses: actions/checkout@v4 |
| 18 | with: |
| 19 | fetch-depth: 0 |
| 20 | - name: Setup Go |
| 21 | uses: actions/setup-go@v5 |
| 22 | with: |
| 23 | go-version-file: go.mod |
| 24 | - name: Build and Test |
| 25 | run: make |
| 26 | docker: |
| 27 | needs: test |
| 28 | runs-on: ubuntu-latest |
| 29 | steps: |
| 30 | - name: Checkout |
| 31 | uses: actions/checkout@v4 |
| 32 | with: |
| 33 | fetch-depth: 0 |
| 34 | - name: Set up QEMU |
| 35 | uses: docker/setup-qemu-action@v3 |
| 36 | - name: Set up Docker Buildx |
| 37 | uses: docker/setup-buildx-action@v3 |
| 38 | - name: Login to GitHub Container Registry |
| 39 | uses: docker/login-action@v3 |
| 40 | if: ${{ github.event_name != 'pull_request' }} |
| 41 | with: |
| 42 | registry: ghcr.io |
| 43 | username: ${{ github.actor }} |
| 44 | password: ${{ secrets.GITHUB_TOKEN }} |
| 45 | - name: Login to Docker hub |
| 46 | uses: docker/login-action@v3 |
| 47 | if: ${{ github.event_name != 'pull_request' }} |
| 48 | with: |
| 49 | username: xperimental |
| 50 | password: ${{ secrets.DOCKER_TOKEN }} |
| 51 | - name: Docker Metadata |
| 52 | id: meta |
| 53 | uses: docker/metadata-action@v5 |
| 54 | with: |
| 55 | images: | |
| 56 | ghcr.io/xperimental/nextcloud-exporter |
| 57 | xperimental/nextcloud-exporter |
| 58 | tags: | |
| 59 | type=semver,pattern={{version}} |
| 60 | type=ref,event=branch |
| 61 | type=ref,event=pr |
| 62 | - name: Build and push Docker images |
| 63 | uses: docker/build-push-action@v5 |
| 64 | with: |
| 65 | context: . |
| 66 | push: ${{ github.event_name != 'pull_request' }} |
| 67 | tags: ${{ steps.meta.outputs.tags }} |
| 68 | labels: ${{ steps.meta.outputs.labels }} |
| 69 | platforms: linux/amd64,linux/arm64 |