diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index b8d95f6..25109f5 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -17,19 +17,16 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Enable corepack - run: corepack enable - - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' - name: Install dependencies - run: yarn install --frozen-lockfile + run: npm install - name: Build - run: yarn build + run: npm run build publish: if: github.ref == 'refs/heads/main' && github.event_name == 'push' @@ -46,17 +43,17 @@ jobs: id: meta uses: docker/metadata-action@v4 with: - images: liamp1/code + images: liamsgit.dev/LiamPietralla/code-snippets tags: | type=raw,value=latest - - name: Login to DockerHub + - name: Login to Registry uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_TOKEN }} + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} - - name: Build and Push Docker Image to DockerHub + - name: Build and Push Docker Image to Registry uses: docker/build-push-action@v4 with: push: true @@ -93,4 +90,6 @@ jobs: export ANSIBLE_HOST_KEY_CHECKING=False # Disable host key checking ansible-playbook infra/ansible/deploy-playbook.yml --private-key private.key --inventory hosts.ini env: - APP_HOST: ${{ secrets.APP_HOST }} \ No newline at end of file + APP_HOST: ${{ secrets.APP_HOST }} + REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }} + REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} \ No newline at end of file diff --git a/infra/ansible/deploy-playbook.yml b/infra/ansible/deploy-playbook.yml index 28cd71e..5d8f643 100644 --- a/infra/ansible/deploy-playbook.yml +++ b/infra/ansible/deploy-playbook.yml @@ -4,4 +4,8 @@ remote_user: root become: yes # sudo roles: - - app \ No newline at end of file + - app + vars: + registry_username: "{{ lookup('env', 'REGISTRY_USERNAME') }}" + registry_password: "{{ lookup('env', 'REGISTRY_PASSWORD') }}" + \ No newline at end of file diff --git a/infra/ansible/roles/app/tasks/main.yml b/infra/ansible/roles/app/tasks/main.yml index 957227f..60ff305 100644 --- a/infra/ansible/roles/app/tasks/main.yml +++ b/infra/ansible/roles/app/tasks/main.yml @@ -1,7 +1,12 @@ +- name: Login to Docker Registry + docker_login: + username: "{{ registry_username }}" + password: "{{ registry_password }}" + - name: Run Code App Container docker_container: name: code - image: liamp1/code:latest + image: liamsgit.dev/LiamPietralla/code-snippets pull: yes ports: - "5000:80"