name: Build & Publish Docker image on: release: types: [ created ] secrets: DOCKER_USERNAME: required: true DOCKER_TOKEN: required: true workflow_dispatch: inputs: version: type: string description: Version number required: true jobs: publish: name: Build & Publish to DockerHub and GitHub Packages runs-on: ubuntu-latest if: contains(github.event.head_commit.message, '[no build]') == false steps: - name: Checkout uses: actions/checkout@v3 with: fetch-depth: 0 - name: Establish variables id: vars run: | VERSION=${{ github.event.inputs.version || github.ref_name }} echo ::set-output name=version::${VERSION} echo ::set-output name=today::$(date +'%Y-%m-%d') echo "::set-output name=year::$(date +'%Y')" - name: Update version number uses: jacobtomlinson/gha-find-replace@2.0.0 with: find: "VERSIONADDEDBYGITHUB" replace: "${{ steps.vars.outputs.version }}" regex: false - name: Update copyright year uses: jacobtomlinson/gha-find-replace@2.0.0 with: find: "YEARADDEDBYGITHUB" replace: "${{ steps.vars.outputs.year }}" regex: false - name: Set up QEMU uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 id: docker-buildx - name: Login to DockerHub uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} - name: Login to GitHub Container Registry uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push uses: docker/build-push-action@v3 with: builder: ${{ steps.docker-buildx.outputs.name }} context: . file: ./Dockerfile push: true platforms: linux/amd64,linux/armhf,linux/arm64 tags: | nwithan8/plex_prerolls:latest nwithan8/plex_prerolls:${{ steps.vars.outputs.version }} ghcr.io/nwithan8/plex_prerolls:latest ghcr.io/nwithan8/plex_prerolls:${{ steps.vars.outputs.version }} labels: | org.opencontainers.image.title=plex_prerolls org.opencontainers.image.version=${{ steps.vars.outputs.version }} org.opencontainers.image.created=${{ steps.vars.outputs.today }}