Skip to content

Commit

Permalink
Fix for tagging
Browse files Browse the repository at this point in the history
  • Loading branch information
jonfairbanks committed Nov 25, 2024
1 parent 4ed0493 commit d28abd3
Showing 1 changed file with 36 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

0 comments on commit d28abd3

Please sign in to comment.