cd: react frontend removed acl public read #6
This file contains 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: CD with Docker and AWS | |
on: | |
push: | |
branches: | |
- 'release/v[0-9]+.[0-9]+' | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: maven | |
- name: Build with Maven | |
working-directory: ./spring_backend | |
run: mvn -B package --file pom.xml | |
- name: Set up Docker buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: login to docker hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.KEI_DOCKER_USERNAME }} | |
password: ${{ secrets.KEI_DOCKER_PASSWORD }} | |
- name: build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./spring_backend | |
push: true | |
tags: ${{ secrets.KEI_DOCKER_USERNAME }}/oracle_spring_backend:${{ github.sha }} | |
- name: Deploy to EC2 | |
env: | |
EC2_SSH_KEY: ${{ secrets.KEI_EC2_SSH_KEY }} | |
EC2_PUBLIC_IPV4: ${{ secrets.KEI_EC2_PUBLIC_IPV4 }} | |
run: | | |
echo "${EC2_SSH_KEY}" > /tmp/key.pem | |
chmod 600 /tmp/key.pem | |
ssh -o StrictHostKeyChecking=no -i /tmp/key.pem ec2-user@${{ env.EC2_PUBLIC_IPV4 }} << 'EOF' | |
docker pull ${{ secrets.KEI_DOCKER_USERNAME }}/oracle_spring_backend:${{ github.sha }} | |
docker stop oracle_spring_backend || true | |
docker rm oracle_spring_backend || true | |
docker run -d \ | |
--name oracle_spring_backend \ | |
-p 8080:8080 \ | |
${{ secrets.KEI_DOCKER_USERNAME }}/oracle_spring_backend:${{ github.sha }} | |
docker logs oracle_spring_backend | |
EOF |