From d3dc794a88d9f72b2251be3981fd5028a011f05d Mon Sep 17 00:00:00 2001 From: Olu Adeyemo Date: Mon, 9 Dec 2024 06:36:32 +0100 Subject: [PATCH] Experimenting with variables 6 --- .github/workflows/deploy.yaml | 76 ++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index fa2b84e..bb67f04 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -31,49 +31,51 @@ jobs: echo ${{ steps.get-version.outputs.version }} - # app_deployment: - # runs-on: ubuntu-latest - # env: - # IMAGE_VERSION: "1123" - # IMAGE_USERNAME: theoafactor - # steps: - # - name: 'Checkout the repo' - # uses: actions/checkout@v4 + app_deployment: + runs-on: ubuntu-latest + needs: + - generate_id + env: + VERSION: ${{ needs.generate_id.outputs.version }} + steps: + - name: 'Checkout the repo' + uses: actions/checkout@v4 - # - name: "Build an image" - # run: | - # docker build -t theoafactor/booksfinder:1124 . + - name: "Build an image" + run: | + + docker build -t theoafactor/booksfinder:${{ needs.generate_id.outputs.version }} . - # - name: 'Log into Docker' - # run: | - # docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }} + - name: 'Log into Docker' + run: | + docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }} - # - name: "Push the image to Docker Hub" - # run: | - # docker push theoafactor/booksfinder:1124 + - name: "Push the image to Docker Hub" + run: | + docker push theoafactor/booksfinder:${{ needs.generate_id.outputs.version }} - # - name: "SSH into EC2 instance" - # env: - # SSH_KEY: ${{ secrets.EC2_PRIVATE_KEY }} - # run: | - # echo "$SSH_KEY" > ssh_key && chmod 600 ssh_key - # ssh -o StrictHostKeyChecking=no -i ssh_key ubuntu@ec2-52-90-75-73.compute-1.amazonaws.com ' + - name: "SSH into EC2 instance" + env: + SSH_KEY: ${{ secrets.EC2_PRIVATE_KEY }} + run: | + echo "$SSH_KEY" > ssh_key && chmod 600 ssh_key + ssh -o StrictHostKeyChecking=no -i ssh_key ubuntu@ec2-52-90-75-73.compute-1.amazonaws.com version=$( echo ${{ needs.generate_id.outputs.version }} ) ' - # sudo apt-get update && - # sudo apt-get install ca-certificates curl -y && - # sudo install -m 0755 -d /etc/apt/keyrings && - # sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc && - # sudo chmod a+r /etc/apt/keyrings/docker.asc && - # echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null && - # sudo apt-get update && - # sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y && - # sudo docker stop $( sudo docker ps -a -q ) && - # sudo docker rm $( sudo docker ps -a -q ) && - # sudo docker rmi $( sudo docker images -q ) && + sudo apt-get update && + sudo apt-get install ca-certificates curl -y && + sudo install -m 0755 -d /etc/apt/keyrings && + sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc && + sudo chmod a+r /etc/apt/keyrings/docker.asc && + echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null && + sudo apt-get update && + sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y && + sudo docker stop $( sudo docker ps -a -q ) && + sudo docker rm $( sudo docker ps -a -q ) && + sudo docker rmi $( sudo docker images -q ) && - # sudo docker pull theoafactor/booksfinder:1124 && - # sudo docker run -d -p 80:80 theoafactor/booksfinder:1124 + sudo docker pull theoafactor/booksfinder:$version && + sudo docker run -d -p 80:80 theoafactor/booksfinder:$version - # ' + ' \ No newline at end of file