CD - Docker - DOCR #15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CD - Docker - DOCR | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| site_tld: | |
| required: false | |
| type: choice | |
| description: "Input: The site tld (variant) to build" | |
| options: | |
| - both | |
| - dev | |
| - org | |
| default: "both" | |
| workflow_call: | |
| inputs: | |
| site_tld: | |
| required: false | |
| type: string | |
| description: "Input: The site tld (variant) to build" | |
| outputs: | |
| tagname: | |
| description: "Output: The tagname for the image built" | |
| value: ${{ jobs.build.outputs.tagname }} | |
| jobs: | |
| build: | |
| name: Build & Push (${{ matrix.site_tld }}) | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| strategy: | |
| matrix: | |
| site_tld: ${{ (inputs.site_tld == 'both' || inputs.site_tld == '') && fromJSON('["dev", "org"]') || fromJSON(format('["{0}"]', inputs.site_tld)) }} | |
| outputs: | |
| tagname: ${{ steps.tagname.outputs.tagname }} | |
| steps: | |
| - name: Checkout Source Files | |
| uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 | |
| - name: Create a tagname | |
| id: tagname | |
| run: | | |
| tagname=$(git rev-parse --short HEAD)-$(date +%Y%m%d)-$(date +%H%M) | |
| echo "tagname=$tagname" >> $GITHUB_ENV | |
| echo "tagname=$tagname" >> $GITHUB_OUTPUT | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3 | |
| - name: Install doctl | |
| uses: digitalocean/action-doctl@v2 | |
| with: | |
| token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | |
| - name: Log in to DigitalOcean Container Registry | |
| run: doctl registry login --expiry-seconds 1200 | |
| - name: Build and push | |
| uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: | | |
| registry.digitalocean.com/${{ secrets.DOCR_NAME }}/${{ matrix.site_tld }}/curriculum-db:${{ env.tagname }} | |
| registry.digitalocean.com/${{ secrets.DOCR_NAME }}/${{ matrix.site_tld }}/curriculum-db:latest | |
| cache-from: type=gha,scope=curriculum-db-${{ matrix.site_tld }} | |
| cache-to: type=gha,mode=max,scope=curriculum-db-${{ matrix.site_tld }} | |
| build-args: | | |
| BUILDKIT_INLINE_CACHE=1 |