chore: fix comment #25
This file contains hidden or 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: CICD | |
on: | |
push: | |
tags: ['*'] | |
branches: [ "main" ] | |
workflow_dispatch: | |
env: | |
DOCKERHUB_REPOSITORY: opositatest/varnish-jwt | |
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }} | |
AWS_REGION: ${{ secrets.AWS_REGION }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
jobs: | |
main: | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Build | |
run: docker compose -f docker-compose.test.yml build | |
- name: Run test | |
run: docker compose -f docker-compose.test.yml up --abort-on-container-exit | |
- name: Get the version | |
id: get_version | |
run: echo ::set-output name=version::${GITHUB_REF/refs\/tags\//} | |
- name: Check if latest | |
id: latest | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
run: echo ::set-output name=latest::true | |
- uses: aws-actions/amazon-ecr-login@v1 | |
id: login-ecr | |
- name: Build, tag and push image to Docker Hub and ECR | |
env: | |
LATEST: ${{ steps.latest.outputs.latest }} | |
VERSION: ${{ steps.get_version.outputs.version }} | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
run: | | |
[[ ${LATEST} == "true" ]] && version="latest" || version=${VERSION} | |
docker build -t ${DOCKERHUB_REPOSITORY}:${version} . | |
docker tag ${DOCKERHUB_REPOSITORY}:${version} ${ECR_REGISTRY}/${ECR_REPOSITORY}:${version} | |
docker push ${DOCKERHUB_REPOSITORY}:${version} | |
docker push ${ECR_REGISTRY}/${ECR_REPOSITORY}:${version} |