|
| 1 | +name: nightly and on.push docker builds |
| 2 | + |
| 3 | +on: |
| 4 | + # to trigger manually if we really need it |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + tag_name: |
| 8 | + description: "the name of the tag for the docker image" |
| 9 | + type: "string" |
| 10 | + required: true |
| 11 | + |
| 12 | + # to trigger |
| 13 | + push: |
| 14 | + paths: |
| 15 | + - Dockerfile |
| 16 | + |
| 17 | + schedule: |
| 18 | + # * is a special character in YAML so you have to quote this string |
| 19 | + # triggers every day at 00:00 UTC (midnight) |
| 20 | + - cron: '0 0 * * *' |
| 21 | + |
| 22 | +jobs: |
| 23 | + docker-amd64: |
| 24 | + environment: 'docker' |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + |
| 29 | + - name: Set up QEMU |
| 30 | + uses: docker/setup-qemu-action@v3 |
| 31 | + |
| 32 | + - name: Set up Docker Buildx |
| 33 | + uses: docker/setup-buildx-action@v3 |
| 34 | + |
| 35 | + - name: Login to Docker Hub |
| 36 | + uses: docker/login-action@v3 |
| 37 | + with: |
| 38 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 39 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 40 | + |
| 41 | + - name: Docker Build and Push |
| 42 | + if: ${{ github.event == 'workflow_dispatch' }} |
| 43 | + uses: docker/build-push-action@v5 |
| 44 | + with: |
| 45 | + push: true |
| 46 | + # build from the ./docker directory in this repo |
| 47 | + context: docker |
| 48 | + platforms: | |
| 49 | + linux/amd64 |
| 50 | + tags: | |
| 51 | + jessebot/nextcloud:${{ inputs.tag_name }} |
| 52 | +
|
| 53 | + # push with ref_name if |
| 54 | + - name: Docker Build and Push |
| 55 | + if: ${{ github.event != 'workflow_dispatch' && github.event != 'schedule' }} |
| 56 | + uses: docker/build-push-action@v5 |
| 57 | + with: |
| 58 | + push: true |
| 59 | + # build from the ./docker directory in this repo |
| 60 | + context: docker |
| 61 | + platforms: | |
| 62 | + linux/amd64 |
| 63 | + tags: | |
| 64 | + jessebot/nextcloud:${{ github.ref_name }} |
| 65 | +
|
| 66 | + - name: Get most recent tag |
| 67 | + if: ${{ github.event == 'schedule' }} |
| 68 | + run: echo "last_tag=$(git describe --tags --abbrev=0) >> $GITHUB_ENV |
| 69 | + |
| 70 | + - name: Docker Build and Push |
| 71 | + if: ${{ github.event == 'schedule' }} |
| 72 | + uses: docker/build-push-action@v5 |
| 73 | + with: |
| 74 | + push: true |
| 75 | + # build from the ./docker directory in this repo |
| 76 | + context: docker |
| 77 | + platforms: | |
| 78 | + linux/amd64 |
| 79 | + tags: | |
| 80 | + jessebot/nextcloud:nightly |
| 81 | + jessebot/nextcloud:${{ env.last_tag }} |
0 commit comments