Update README #174
This file contains 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: Push docker image | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
test: | |
name: Testing | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres | |
ports: | |
- "5432:5432" | |
env: | |
POSTGRES_PASSWORD: password | |
POSTGRES_USER: nebula_test | |
POSTGRES_DB: nebula_test | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- name: Checking out repository code | |
uses: actions/checkout@v4 | |
- name: Setting up Golang | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.23' | |
- name: Running tests | |
run: make test | |
push_to_dockerhub: | |
name: Push Docker image to Docker Hub | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: dennistra/nebula-crawler | |
tags: | | |
type=sha | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
push_to_ecr: | |
name: Push Docker image to ProbeLab's ECR | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- name: Checking out the repo | |
uses: actions/checkout@v4 | |
- name: Configuring AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: us-east-1 | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | |
aws-secret-access-key: ${{ secrets.AWS_ACCESS_SECRET }} | |
- name: Log in to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Build, tag, and push docker image to Amazon ECR | |
env: | |
REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
REPOSITORY: probelab | |
run: | | |
SHA_SHORT=${{ github.sha }} | |
SHA_SHORT=${SHA_SHORT::7} | |
IMAGE_TAG="nebula-sha${SHA_SHORT}" | |
docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG . | |
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG |