Skip to content

Commit

Permalink
Merge pull request #272 from jonfairbanks/fixes/clean-up
Browse files Browse the repository at this point in the history
Fix for tagging
  • Loading branch information
jonfairbanks authored Nov 25, 2024
2 parents bba941b + 0565f06 commit 1ca81e6
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 22 deletions.
58 changes: 36 additions & 22 deletions .github/workflows/docker-build-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,27 @@ env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

jobs:
configure:
name: Configure
runs-on: ubuntu-latest
steps:
- name: Setup deployment variables
id: setup-vars
run: |
BRANCH_NAME=$(echo "${{ github.ref }}" | sed 's|refs/heads/||')
echo "Branch: $BRANCH_NAME"
if [ "$BRANCH_NAME" = "develop" ]; then
echo "Using Development"
echo "environment=development" >> $GITHUB_OUTPUT
echo "aws_key=${{ secrets.aws_access_key_id }}" >> $GITHUB_OUTPUT
echo "aws_secret=${{ secrets.aws_secret_access_key }}" >> $GITHUB_OUTPUT
elif [ "$BRANCH_NAME" = "main" ]; then
echo "Using Production"
echo "environment=production" >> $GITHUB_OUTPUT
echo "aws_key=${{ secrets.aws_access_key_id }}" >> $GITHUB_OUTPUT
echo "aws_secret=${{ secrets.aws_secret_access_key }}" >> $GITHUB_OUTPUT
fi
node-lint:
name: Lint Node.js
runs-on: ubuntu-latest
Expand Down Expand Up @@ -82,19 +103,6 @@ jobs:
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build & Push to DockerHub
id: docker_build
uses: docker/build-push-action@v6
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./src
platforms: linux/amd64,linux/arm64
file: ./src/Dockerfile
push: true
tags: ${{ github.repository }}:develop
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
Expand All @@ -108,15 +116,21 @@ jobs:
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: 'true'

- name: Build & Push to Amazon ECR
env:
REGISTRY: ${{ steps.ecr-login.outputs.registry }}
REPOSITORY: yo-api
IMAGE_TAG: develop
run: |
docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG

- name: Build & Push Docker image(s)
id: docker-build
uses: docker/build-push-action@v6
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./src
platforms: linux/amd64,linux/arm64
file: ./src/Dockerfile
push: true
tags: |
${{ github.repository }}:develop
${{ steps.ecr-login.outputs.registry }}/yo-api:develop
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

- name: Notify Slack
uses: act10ns/slack@v2
Expand Down
12 changes: 12 additions & 0 deletions src/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3.8'

services:
yo-api:
# build:
# context: .
# dockerfile: src/Dockerfile
image: jonfairbanks/yo-api
ports:
- "3000:3000"
env_file:
- .env.development

0 comments on commit 1ca81e6

Please sign in to comment.