Configure AWS environment variables in workflow #20
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: Docker Image CI | |
| on: | |
| push: | |
| branches: [ "master" ] | |
| pull_request: | |
| branches: [ "master" ] | |
| env: | |
| AWS_REGION: us-east-1 | |
| EKS_CLUSTER_NAME: EKSCluster | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Maven Build | |
| run: mvn clean install | |
| - name: Build the Docker image | |
| run: docker build . --file Dockerfile --tag my-image-name:$(date +%s) | |
| - name: 'Build and push image' | |
| uses: rtvu/build-and-push-to-docker-hub-action@v2 | |
| with: | |
| tags: latest | |
| image: ${{ secrets.DOCKER_HUB_USERNAME }}/springbootsony | |
| token: ${{ secrets.DOCKER_HUB_TOKEN }} | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| - name: ecr-publish | |
| uses: bitovi/github-actions-ecr-publish@v0.1.0 | |
| with: | |
| aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws_default_region: us-east-1 | |
| checkout: false | |
| aws_ecr_repo_name: 'hello-repo' | |
| - name: Deploy | |
| uses: cancue/eks-action@v0.0.2 | |
| env: | |
| aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws_region: $AWS_REGION | |
| cluster_name: $EKS_CLUSTER_NAME | |
| with: | |
| args: | | |
| kubectl cluster-info |