Docker Build #37
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: Docker Build | |
| on: | |
| push: | |
| # ALL branches | |
| branches: ['**'] | |
| tags: | |
| - 'v*' | |
| - '*.*.*' | |
| schedule: | |
| - cron: '0 4 * * *' | |
| workflow_dispatch: | |
| concurrency: | |
| group: docker-${{ github.ref }} | |
| cancel-in-progress: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/devel' || github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/beta' }} | |
| env: | |
| PROJECT_NAME: shortner | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| build-standard: | |
| runs-on: ubuntu-latest | |
| if: github.event_name != 'schedule' | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4.1.0 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0 | |
| - name: Log in to Container Registry | |
| uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set build info | |
| run: | | |
| echo "COMMIT_ID=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
| echo "YYMM=$(date +"%y%m")" >> $GITHUB_ENV | |
| if [[ "${{ github.ref }}" == refs/tags/* ]]; then | |
| VERSION="${GITHUB_REF#refs/tags/}" | |
| echo "VERSION=${VERSION#v}" >> $GITHUB_ENV | |
| echo "IS_TAG=true" >> $GITHUB_ENV | |
| else | |
| echo "VERSION=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
| echo "IS_TAG=false" >> $GITHUB_ENV | |
| fi | |
| BUILD_EPOCH=$(date -u +%s) | |
| echo "BUILD_EPOCH=${BUILD_EPOCH}" >> $GITHUB_ENV | |
| echo "BUILD_DATE=$(date -u -d @${BUILD_EPOCH} +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV | |
| - name: Determine tags (standard) | |
| id: tags | |
| run: | | |
| TAGS="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.COMMIT_ID }}" | |
| if [[ "${{ env.IS_TAG }}" == "true" ]]; then | |
| TAGS="$TAGS,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}" | |
| TAGS="$TAGS,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" | |
| TAGS="$TAGS,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.YYMM }}" | |
| else | |
| if [[ "${{ github.ref }}" == refs/heads/beta ]]; then | |
| TAGS="$TAGS,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:beta" | |
| fi | |
| fi | |
| echo "tags=$TAGS" >> $GITHUB_OUTPUT | |
| - name: Build and push (standard) | |
| uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0 | |
| with: | |
| context: . | |
| file: docker/Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| provenance: false | |
| tags: ${{ steps.tags.outputs.tags }} | |
| build-args: | | |
| VERSION=${{ env.VERSION }} | |
| BUILD_DATE=${{ env.BUILD_DATE }} | |
| BUILD_EPOCH=${{ env.BUILD_EPOCH }} | |
| COMMIT_ID=${{ env.COMMIT_ID }} | |
| labels: | | |
| org.opencontainers.image.vendor=apimgr | |
| org.opencontainers.image.authors=apimgr | |
| org.opencontainers.image.title=${{ env.PROJECT_NAME }} | |
| org.opencontainers.image.base.name=${{ env.PROJECT_NAME }} | |
| org.opencontainers.image.description=${{ env.PROJECT_NAME }} - standard image (alpine) | |
| org.opencontainers.image.version=${{ env.VERSION }} | |
| org.opencontainers.image.created=${{ env.BUILD_DATE }} | |
| org.opencontainers.image.revision=${{ env.COMMIT_ID }} | |
| org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }} | |
| org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} | |
| org.opencontainers.image.documentation=${{ github.server_url }}/${{ github.repository }} | |
| org.opencontainers.image.licenses=MIT | |
| annotations: | | |
| manifest:org.opencontainers.image.vendor=apimgr | |
| manifest:org.opencontainers.image.authors=apimgr | |
| manifest:org.opencontainers.image.title=${{ env.PROJECT_NAME }} | |
| manifest:org.opencontainers.image.base.name=${{ env.PROJECT_NAME }} | |
| manifest:org.opencontainers.image.description=${{ env.PROJECT_NAME }} - standard image (alpine) | |
| manifest:org.opencontainers.image.version=${{ env.VERSION }} | |
| manifest:org.opencontainers.image.created=${{ env.BUILD_DATE }} | |
| manifest:org.opencontainers.image.revision=${{ env.COMMIT_ID }} | |
| manifest:org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }} | |
| manifest:org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} | |
| manifest:org.opencontainers.image.documentation=${{ github.server_url }}/${{ github.repository }} | |
| manifest:org.opencontainers.image.licenses=MIT | |
| build-devel: | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')) | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4.1.0 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0 | |
| - name: Log in to Container Registry | |
| uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set build info | |
| run: | | |
| echo "COMMIT_ID=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
| BUILD_EPOCH=$(date -u +%s) | |
| echo "BUILD_EPOCH=${BUILD_EPOCH}" >> $GITHUB_ENV | |
| echo "BUILD_DATE=$(date -u -d @${BUILD_EPOCH} +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV | |
| - name: Build and push (devel) | |
| uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0 | |
| with: | |
| context: . | |
| file: docker/Dockerfile.dev | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| provenance: false | |
| tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:devel | |
| build-args: | | |
| BUILD_DATE=${{ env.BUILD_DATE }} | |
| BUILD_EPOCH=${{ env.BUILD_EPOCH }} | |
| COMMIT_ID=${{ env.COMMIT_ID }} | |
| labels: | | |
| org.opencontainers.image.vendor=apimgr | |
| org.opencontainers.image.authors=apimgr | |
| org.opencontainers.image.title=${{ env.PROJECT_NAME }} | |
| org.opencontainers.image.base.name=${{ env.PROJECT_NAME }} | |
| org.opencontainers.image.description=${{ env.PROJECT_NAME }} - development image (alpine, debug mode) | |
| org.opencontainers.image.created=${{ env.BUILD_DATE }} | |
| org.opencontainers.image.revision=${{ env.COMMIT_ID }} | |
| org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }} | |
| org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} | |
| org.opencontainers.image.documentation=${{ github.server_url }}/${{ github.repository }} | |
| org.opencontainers.image.licenses=MIT | |
| annotations: | | |
| manifest:org.opencontainers.image.vendor=apimgr | |
| manifest:org.opencontainers.image.authors=apimgr | |
| manifest:org.opencontainers.image.title=${{ env.PROJECT_NAME }} | |
| manifest:org.opencontainers.image.base.name=${{ env.PROJECT_NAME }} | |
| manifest:org.opencontainers.image.description=${{ env.PROJECT_NAME }} - development image (alpine, debug mode) | |
| manifest:org.opencontainers.image.created=${{ env.BUILD_DATE }} | |
| manifest:org.opencontainers.image.revision=${{ env.COMMIT_ID }} | |
| manifest:org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }} | |
| manifest:org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} | |
| manifest:org.opencontainers.image.documentation=${{ github.server_url }}/${{ github.repository }} | |
| manifest:org.opencontainers.image.licenses=MIT |