Skip to content

feat: Introduce Celery tasks overview, enhance pod detail fetching wi… #309

feat: Introduce Celery tasks overview, enhance pod detail fetching wi…

feat: Introduce Celery tasks overview, enhance pod detail fetching wi… #309

name: "VPC Agent build"
#run-name: "VPC Agent updated by ${{ github.actor }} and run by ${{ github.triggering_actor }}"
on:
pull_request:
paths:
- .github/workflows/build-and-push.yaml
- "**"
branches:
- "main"
push:
paths:
- .github/workflows/build-and-push.yaml
- "**"
branches:
- "main"
permissions: write-all
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
setup:
runs-on: warp-ubuntu-latest-x64-16x-spot
outputs:
SHORT_SHA: ${{ steps.setup.outputs.SHORT_SHA }}
EPOCH_TIMESTAMP: ${{ steps.setup.outputs.EPOCH_TIMESTAMP }}
MONTH: ${{ steps.setup.outputs.MONTH }}
YEAR: ${{ steps.setup.outputs.YEAR }}
CLEAN_BRANCH_NAME: ${{ steps.setup.outputs.CLEAN_BRANCH_NAME }}
steps:
- name: Set variables
id: setup
run: |
echo "SHORT_SHA=${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
echo "EPOCH_TIMESTAMP=$(date +%s)" >> $GITHUB_OUTPUT
echo "MONTH=$(date +%m)" >> $GITHUB_OUTPUT
echo "YEAR=$(date +%Y)" >> $GITHUB_OUTPUT
# Handle both PR and push events
if [ "${{ github.event_name }}" = "pull_request" ]; then
BRANCH_NAME="${{ github.base_ref }}"
else
BRANCH_NAME=${GITHUB_REF#refs/heads/}
fi
echo "CLEAN_BRANCH_NAME=$(echo ${BRANCH_NAME} | tr '/' '-')" >> $GITHUB_OUTPUT
build:
needs: [setup]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_TEAM_NAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and Tag
env:
IMAGE_TAG_SHA: ${{ needs.setup.outputs.SHORT_SHA }}
IMAGE_TAG_BRANCH: ${{ needs.setup.outputs.CLEAN_BRANCH_NAME }}-${{ needs.setup.outputs.EPOCH_TIMESTAMP }}
IMAGE_TAG_BRANCH_ORIG: ${{ needs.setup.outputs.CLEAN_BRANCH_NAME }}
IMAGE_TAG_EPOCH_TIMESTAMP: ${{ needs.setup.outputs.EPOCH_TIMESTAMP }}
REPO_NAME: ${{ secrets.DOCKERHUB_TEAM_NAME }}/drd-vpc-agent
GHCR_REPO: ghcr.io/drdroidlab/drd-vpc-agent/drd-vpc-agent
EVENT_NAME: ${{ github.event_name }}
run: |
echo "Building for repository"
if [ "$EVENT_NAME" = "push" ]; then
EXPORT_FLAG="--push"
PLATFORMS="linux/amd64,linux/arm64"
else
EXPORT_FLAG="--load"
PLATFORMS="linux/amd64"
fi
docker buildx build \
--platform $PLATFORMS \
--tag ${REPO_NAME}:$IMAGE_TAG_SHA \
--tag ${REPO_NAME}:$IMAGE_TAG_EPOCH_TIMESTAMP \
--tag ${REPO_NAME}:$IMAGE_TAG_BRANCH_ORIG \
--tag ${REPO_NAME}:$IMAGE_TAG_BRANCH \
--tag ${REPO_NAME}:latest \
--tag ${GHCR_REPO}:$IMAGE_TAG_SHA \
--tag ${GHCR_REPO}:$IMAGE_TAG_EPOCH_TIMESTAMP \
--tag ${GHCR_REPO}:$IMAGE_TAG_BRANCH_ORIG \
--tag ${GHCR_REPO}:$IMAGE_TAG_BRANCH \
--tag ${GHCR_REPO}:latest \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--build-arg COMMIT_HASH=$IMAGE_TAG_SHA \
--file Dockerfile \
$EXPORT_FLAG \
.