Skip to content

Commit

Permalink
Add dataapi builder on docker
Browse files Browse the repository at this point in the history
  • Loading branch information
hellais committed Jan 18, 2024
1 parent c0e48ec commit 0287799
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/build_dataapi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build and Deploy Docker Image for dataapi

on:
push:
branches:
- 2024-refactor
paths:
- "api/fastapi/**"

env:
IMAGE_NAME: ooni/dataapi
DOCKERFILE_PATH: ./api/fastapi/

jobs:
build_and_push:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Format version number
id: version
run: |
DATE=$(date +'%Y%m%d')
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-4)
TAG="v${DATE}-${SHORT_SHA}"
echo "::set-output name=tag::$TAG"
- name: Build and Push Docker Image
run: |
TAG_LATEST=$IMAGE_NAME:latest
TAG_ENVIRONMENT=$IMAGE_NAME:production
TAG_VERSION=$IMAGE_NAME:${{ steps.prep.outputs.tag }}
# Build Docker image with multiple tags
docker build -t $TAG_LATEST -t $TAG_VERSION -t $TAG_ENVIRONMENT $DOCKERFILE_PATH
# Push all tags
docker push $TAG_LATEST
docker push $TAG_VERSION
docker push $TAG_ENVIRONMENT

0 comments on commit 0287799

Please sign in to comment.