Build and publish #679
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: Build and publish | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 1 * * *" | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: AWS CLI v2 | |
| uses: imehedi/actions-awscli-v2@latest | |
| continue-on-error: true | |
| with: | |
| args: s3 cp s3://${{ vars.SC_ARTIFACTS_BUCKET }}/pgbouncer-docker/REVISION . --endpoint-url ${{ vars.SC_AMS_AWS_ENDPOINT }} | |
| env: | |
| AWS_ACCESS_KEY_ID: ${{ secrets.SC_AWS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.SC_AWS_SECRET_ACCESS_KEY }} | |
| AWS_DEFAULT_REGION: "nl-ams" | |
| - name: Tag | |
| id: tag | |
| run: | | |
| git clone https://github.com/pgbouncer/pgbouncer.git | |
| REPO_TAG=$(git --git-dir=pgbouncer/.git tag | sort -V | tail -n 1 | tr '_' '.' | sed -e 's/^pgbouncer.//') | |
| PREVIOUS_TAG=$(cat REVISION || echo "") | |
| mkdir temp/ | |
| if [ "$REPO_TAG" = "$PREVIOUS_TAG" ]; then | |
| echo "No new tags. Skipping." | |
| echo "skipped=true" >> $GITHUB_OUTPUT | |
| echo $REPO_TAG > temp/REVISION | |
| exit 0 | |
| fi | |
| VERSION="$REPO_TAG" | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| echo $REPO_TAG > temp/REVISION | |
| - name: AWS CLI v2 | |
| uses: imehedi/actions-awscli-v2@latest | |
| with: | |
| args: s3 cp temp/REVISION s3://${{ vars.SC_ARTIFACTS_BUCKET }}/pgbouncer-docker/REVISION --endpoint-url ${{ vars.SC_AMS_AWS_ENDPOINT }} | |
| env: | |
| AWS_ACCESS_KEY_ID: ${{ secrets.SC_AWS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.SC_AWS_SECRET_ACCESS_KEY }} | |
| AWS_DEFAULT_REGION: "nl-ams" | |
| - name: Set up QEMU | |
| if: ${{ steps.tag.outputs.skipped != 'true' }} | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| if: ${{ steps.tag.outputs.skipped != 'true' }} | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| if: ${{ steps.tag.outputs.skipped != 'true' }} | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ghcr.io/icoretech/pgbouncer-docker | |
| labels: | | |
| io.artifacthub.package.category=database | |
| io.artifacthub.package.keywords=postgresql,postgres,pgbouncer | |
| io.artifacthub.package.license=MIT | |
| io.artifacthub.package.maintainers=[{"name":"Claudio Poli","email":"[email protected]"}] | |
| io.artifacthub.package.readme-url=https://github.com/icoretech/pgbouncer-docker/blob/main/README.md | |
| org.opencontainers.image.description=PgBouncer | |
| org.opencontainers.image.source=https://github.com/icoretech/pgbouncer-docker | |
| org.opencontainers.image.title=pgbouncer | |
| org.opencontainers.image.vendor=iCoreTech, Inc. | |
| tags: | | |
| type=raw,value=${{ env.VERSION }} | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| if: ${{ steps.tag.outputs.skipped != 'true' }} | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.PACKAGES_PAT }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| if: ${{ steps.tag.outputs.skipped != 'true' }} | |
| with: | |
| platforms: linux/amd64,linux/arm64 | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| provenance: mode=max | |
| build-args: REPO_TAG=${{ env.VERSION }} |