Release custom DBtune PostgreSQL exporter #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: Release custom DBtune PostgreSQL exporter | |
on: | |
workflow_dispatch: | |
inputs: | |
semver: | |
description: "Semver string for the image tag (ex. 0.0.1)" | |
required: true | |
default: "latest" | |
jobs: | |
release-image: | |
name: "Build and Push to ACR" | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: '>=1.21.0' | |
- name: Install Task | |
uses: arduino/setup-task@v1 | |
with: | |
version: 3.x | |
- name: Replace semver in make file | |
run: sed -i 's/latest-image-tag/${{ github.event.inputs.semver }}/' ./Makefile.common | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 # More information on this action can be found below in the 'AWS Credentials' section | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: Log in to Amazon ECR Public | |
id: login-ecr-public | |
uses: aws-actions/amazon-ecr-login@v2 | |
with: | |
registry-type: 'public' | |
- name: Build images | |
run: task build | |
# Push AMD64 image to public ECR | |
- name: Tag and Push AMD64 image to public ECR | |
run: | | |
docker tag dbtuneai/dbtune-postgres-exporter-linux-amd64:${{ github.event.inputs.semver }} public.ecr.aws/dbtune/dbtuneai/postgres_exporter:${{ github.event.inputs.semver }}-amd64 | |
docker push public.ecr.aws/dbtune/dbtuneai/postgres_exporter:${{ github.event.inputs.semver }}-amd64 | |
# Push ARM64 image to public ECR | |
- name: Tag and Push ARM64 image to public ECR | |
run: | | |
docker tag dbtuneai/dbtune-postgres-exporter-linux-arm64:${{ github.event.inputs.semver }} public.ecr.aws/dbtune/dbtuneai/postgres_exporter:${{ github.event.inputs.semver }}-arm64 | |
docker push public.ecr.aws/dbtune/dbtuneai/postgres_exporter:${{ github.event.inputs.semver }}-arm64 | |
# Create and push manifest for multi-arch support to public ECR | |
- name: Create and Push manifest to public ECR | |
run: | | |
docker manifest create public.ecr.aws/dbtune/dbtuneai/postgres_exporter:${{ github.event.inputs.semver }} \ | |
public.ecr.aws/dbtune/dbtuneai/postgres_exporter:${{ github.event.inputs.semver }}-amd64 \ | |
public.ecr.aws/dbtune/dbtuneai/postgres_exporter:${{ github.event.inputs.semver }}-arm64 | |
docker manifest push public.ecr.aws/dbtune/dbtuneai/postgres_exporter:${{ github.event.inputs.semver }} | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 # More information on this action can be found below in the 'AWS Credentials' section | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: eu-north-1 | |
- name: Log in to Amazon ECR Private | |
id: login-ecr-private | |
uses: aws-actions/amazon-ecr-login@v2 | |
with: | |
registry-type: 'private' | |
# Push AMD64 image to private ECR | |
- name: Tag and Push AMD64 image to private ECR | |
run: | | |
docker tag dbtuneai/dbtune-postgres-exporter-linux-amd64:${{ github.event.inputs.semver }} 988456582933.dkr.ecr.eu-north-1.amazonaws.com/postgres_exporter:${{ github.event.inputs.semver }}-amd64 | |
docker push 988456582933.dkr.ecr.eu-north-1.amazonaws.com/postgres_exporter:${{ github.event.inputs.semver }}-amd64 | |
# Push ARM64 image to private ECR | |
- name: Tag and Push ARM64 image to private ECR | |
run: | | |
docker tag dbtuneai/dbtune-postgres-exporter-linux-arm64:${{ github.event.inputs.semver }} 988456582933.dkr.ecr.eu-north-1.amazonaws.com/postgres_exporter:${{ github.event.inputs.semver }}-arm64 | |
docker push 988456582933.dkr.ecr.eu-north-1.amazonaws.com/postgres_exporter:${{ github.event.inputs.semver }}-arm64 | |
# Create and push manifest for multi-arch support to private ECR | |
- name: Create and Push manifest to private ECR | |
run: | | |
docker manifest create 988456582933.dkr.ecr.eu-north-1.amazonaws.com/postgres_exporter:${{ github.event.inputs.semver }} \ | |
988456582933.dkr.ecr.eu-north-1.amazonaws.com/postgres_exporter:${{ github.event.inputs.semver }}-amd64 \ | |
988456582933.dkr.ecr.eu-north-1.amazonaws.com/postgres_exporter:${{ github.event.inputs.semver }}-arm64 | |
docker manifest push 988456582933.dkr.ecr.eu-north-1.amazonaws.com/postgres_exporter:${{ github.event.inputs.semver }} | |
- name: Create GitHub Tag | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
# Delete the tag locally and remotely if it's "latest" | |
if [ "${{ github.event.inputs.semver }}" = "latest" ]; then | |
git tag -d latest || true | |
git push --delete origin latest || true | |
fi | |
# Create and push the new tag | |
git tag ${{ github.event.inputs.semver }} | |
git push origin ${{ github.event.inputs.semver }} |