Skip to content

chore: build and push docker image using github actions #12

chore: build and push docker image using github actions

chore: build and push docker image using github actions #12

Workflow file for this run

name: "build-push"
on:
push:
branches:
- main
pull_request:
env:
GO_VERSION: 1.21.8
permissions:
contents: read
id-token: write
jobs:
build-push:
runs-on: ubuntu-latest
steps:
- id: checkout
uses: actions/checkout@v4
- name: Setup Docker Variables
run: |
bash scripts/generate-tags.sh > .tag
if [ ${{ github.event_name }} == 'push' ]; then
echo "DOCKER_REGISTRY=us-docker.pkg.dev/grafanalabs-global/docker-influx2cortex-prod" >> $GITHUB_ENV
echo "DOCKER_ENV=prod" >> $GITHUB_ENV
echo -e "DOCKER_TAGS=\"$(cat .tag)\nlatest\"" >> $GITHUB_ENV
else
echo "DOCKER_REGISTRY=us-docker.pkg.dev/grafanalabs-dev/docker-influx2cortex-dev" >> $GITHUB_ENV
echo "DOCKER_ENV=dev" >> $GITHUB_ENV
echo -e "DOCKER_TAGS=\"$(cat .tag)\nnotlatest\"" >> $GITHUB_ENV
fi
- name: Build And Push
id: build-and-push
uses: grafana/shared-workflows/actions/push-to-gar-docker@main
with:
push: true
registry: ${{ env.DOCKER_REGISTRY }}
tags: "${{ env.DOCKER_TAGS }}"
context: "."
image_name: "influx2cortex"
environment: ${{ env.DOCKER_ENV }}
- name: Print Image Details
id: print-image-details
run: |
echo Built and pushed image
echo ${{ steps.build-and-push.outputs.json }}