name: docker build on: release: types: - released workflow_dispatch: inputs: branch: description: 'Select branch' required: true type: choice options: - master - develop tag: description: 'Add a tag' push: branches: - develop paths-ignore: - '.github/**' jobs: push_to_ghcr_io: runs-on: ubuntu-latest steps: - name: checkout uses: actions/checkout@v2 with: fetch-depth: 0 - name: Get the version id: get_version run: echo ::set-output name=VERSION::${{ github.event.release.tag_name }} - name: Set current date as env variable id: date_time run: echo ::set-output name=NOW::$(date +'%Y-%m-%dT%H:%M:%S') - name: Login to GitHub Container Registry uses: docker/login-action@v1 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GH_PAT }} - name: build&push master if: ${{ github.event.release.target_commitish == 'master' }} run: | docker build --build-arg TP_RELEASE=${{ steps.get_version.outputs.VERSION }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag ghcr.io/gilbn/theme.park --tag ghcr.io/gilbn/theme.park:${{ steps.get_version.outputs.VERSION }} . docker push --all-tags ghcr.io/gilbn/theme.park if: ${{ github.event.inputs.branch == 'master' }} run: | docker build --build-arg TP_RELEASE=${{ github.event.inputs.tag }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag ghcr.io/gilbn/theme.park --tag ghcr.io/gilbn/theme.park:${{ github.event.inputs.tag }} . docker push --all-tags ghcr.io/gilbn/theme.park - name: build&push develop if: ${{ github.ref == 'refs/heads/develop' || github.event.inputs.branch == 'develop' }} run: | docker build --build-arg TP_RELEASE=${{ steps.get_version.outputs.VERSION }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag ghcr.io/gilbn/theme.park:develop . docker push --all-tags ghcr.io/gilbn/theme.park push_to_dockerhub: runs-on: ubuntu-latest steps: - name: checkout uses: actions/checkout@v2 with: fetch-depth: 0 - name: Get the version id: get_version run: echo ::set-output name=VERSION::${{ github.event.release.tag_name }} - name: Set current date as env variable id: date_time run: echo ::set-output name=NOW::$(date +'%Y-%m-%dT%H:%M:%S') - name: Login to Docker Hub uses: docker/login-action@v1 with: username: ${{ secrets.DH_USER }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: build&push dh master if: ${{ github.event.release.target_commitish == 'master' }} run: | docker build --build-arg TP_RELEASE=${{ steps.get_version.outputs.VERSION }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag gilbn/theme.park --tag gilbn/theme.park:${{ steps.get_version.outputs.VERSION }} . docker push --all-tags gilbn/theme.park if: ${{ github.event.inputs.branch == 'master' }} run: | docker build --build-arg TP_RELEASE=${{ github.event.inputs.tag }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag gilbn/theme.park --tag gilbn/theme.park:${{ github.event.inputs.tag }} . docker push --all-tags gilbn/theme.park - name: build&push dh develop if: ${{ github.ref == 'refs/heads/develop' || github.event.inputs.branch == 'develop' }} run: | docker build --build-arg TP_RELEASE=${{ steps.get_version.outputs.VERSION }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag gilbn/theme.park:develop . docker push --all-tags gilbn/theme.park