Skip to content

Commit

Permalink
Merge pull request RocketChat#949 from WideChat/ear_push_to_acc_workflow
Browse files Browse the repository at this point in the history
[IMPROVE] push images to ACC:rocketchat in ECR
  • Loading branch information
ear-dev authored Sep 27, 2021
2 parents aff8737 + e4d2fa4 commit d2611ba
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,6 @@ jobs:
docker build -t ${IMAGE}:develop .
docker push ${IMAGE}:develop
# TODO: configure for merges to develop when ready
# NOTE: Right now it will only push on every merge into develop_pwa because we have a standing PR from it -> develop.
widechat-ecr-push:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/develop_pwa' && github.event_name == 'push' }}
Expand All @@ -576,11 +574,9 @@ jobs:

- name: Parse for branch
run: |
git_ref=${{ github.ref }}
arrRef=(${git_ref//\// })
branch=${arrRef[2]}
echo "branch is this: $branch"
echo "PR_TAG=latest-$branch" >> $GITHUB_ENV
git_hash=$(git rev-parse --short "$GITHUB_SHA")
rocket_version=$(node -pe "require('./package.json').version")
echo "PR_TAG=v$rocket_version.$git_hash" >> $GITHUB_ENV
- name: Restore build
uses: actions/download-artifact@v1
Expand Down Expand Up @@ -643,3 +639,26 @@ jobs:
# Tag docker image and push it to ECR
docker tag ${{ steps.build-image-dev.outputs.DEV_IMAGE }} $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
## Push to ACC:rocketchat
- name: Configure AWS credentials in ACC
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.ACC_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.ACC_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Login to Amazon ECR
id: login-ecr-acc
uses: aws-actions/amazon-ecr-login@v1

- name: tag, and push image to Amazon ECR in ACC
env:
ECR_REGISTRY: ${{ steps.login-ecr-acc.outputs.registry }}
ECR_REPOSITORY: rocketchat
IMAGE_TAG: ${{ env.PR_TAG }}

run: |
# Tag docker image and push it to ECR
docker tag ${{ steps.build-image-dev.outputs.DEV_IMAGE }} $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG

0 comments on commit d2611ba

Please sign in to comment.