diff --git a/.github/actions/docker/deploy/action.yml b/.github/actions/docker/deploy/action.yml new file mode 100644 index 00000000..24674e0e --- /dev/null +++ b/.github/actions/docker/deploy/action.yml @@ -0,0 +1,35 @@ +name: Docker deploy + +inputs: + REGISTRY_URL: + required: true + type: string + PROJECT_NAME: + required: true + type: string + DOCKER_COMPOSE_PATH: + required: true + type: string + DOCKER_COMPOSE_EXTRA_ARGS: + required: false + type: string + default: '' + +runs: + using: composite + + steps: + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ inputs.REGISTRY_URL }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Pull docker images + shell: 'bash' + run: docker-compose --project-name ${{ inputs.PROJECT_NAME }} -f ${{ inputs.DOCKER_COMPOSE_PATH }} ${{ inputs.DOCKER_COMPOSE_EXTRA_ARGS }} pull + - name: Run docker-compose up + shell: 'bash' + run: docker-compose --project-name ${{ inputs.PROJECT_NAME }} -f ${{ inputs.DOCKER_COMPOSE_PATH }} ${{ inputs.DOCKER_COMPOSE_EXTRA_ARGS }} up --build --remove-orphans --force-recreate -d + + diff --git a/.github/workflows/docker-step-deploy.yml b/.github/workflows/docker-step-deploy.yml index f637b215..f2b58320 100644 --- a/.github/workflows/docker-step-deploy.yml +++ b/.github/workflows/docker-step-deploy.yml @@ -40,7 +40,8 @@ on: env: "${{secrets}}" jobs: - deploy: + deploy-with-runner-group: + if: ${{ inputs.RUNNERS_CONTAINER_GROUP != '' }} runs-on: labels: - deploy @@ -56,11 +57,34 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Log in to the Container registry - uses: docker/login-action@v2 + - name: Deploy + uses: zupit-it/pipeline-templates/.github/actions/docker/deploy@v1.22.6 with: - registry: ${{ inputs.REGISTRY_URL }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - run: docker-compose --project-name ${{ inputs.PROJECT_NAME }} -f ${{ inputs.DOCKER_COMPOSE_PATH }} ${{ inputs.DOCKER_COMPOSE_EXTRA_ARGS }} pull - - run: docker-compose --project-name ${{ inputs.PROJECT_NAME }} -f ${{ inputs.DOCKER_COMPOSE_PATH }} ${{ inputs.DOCKER_COMPOSE_EXTRA_ARGS }} up --build --remove-orphans --force-recreate -d + REGISTRY_URL: ${{ inputs.REGISTRY_URL }} + PROJECT_NAME: ${{ inputs.PROJECT_NAME }} + DOCKER_COMPOSE_PATH: ${{ inputs.DOCKER_COMPOSE_PATH }} + DOCKER_COMPOSE_EXTRA_ARGS: ${{ inputs.DOCKER_COMPOSE_EXTRA_ARGS }} + + deploy-without-runner-group: + if: ${{ inputs.RUNNERS_CONTAINER_GROUP == '' }} + runs-on: + labels: + - deploy + - ${{ inputs.DEPLOY_ON }} + env: ${{ fromJson(inputs.IMAGES) }} + environment: + name: ${{ inputs.ENVIRONMENT }} + url: ${{ inputs.DEPLOY_URL }} + container: + image: ${{ inputs.DIND_IMAGE }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Deploy + uses: zupit-it/pipeline-templates/.github/actions/docker/deploy@v1.22.6 + with: + REGISTRY_URL: ${{ inputs.REGISTRY_URL }} + PROJECT_NAME: ${{ inputs.PROJECT_NAME }} + DOCKER_COMPOSE_PATH: ${{ inputs.DOCKER_COMPOSE_PATH }} + DOCKER_COMPOSE_EXTRA_ARGS: ${{ inputs.DOCKER_COMPOSE_EXTRA_ARGS }}