Difference between revisions of "My-docker-publish.yml"
Jump to navigation
Jump to search
Line 6: | Line 6: | ||
[[env:]] | [[env:]] | ||
ACTIONS_RUNNER_DEBUG: true | ACTIONS_RUNNER_DEBUG: true | ||
− | #AWS_REGION: MY_AWS_REGION | + | #AWS_REGION: MY_AWS_REGION |
− | ECR_REPOSITORY: your-repo | + | ECR_REPOSITORY: your-repo |
ECR_REGISTRY: 12312432424234.dkr.ecr.eu-west-1.amazonaws.com | ECR_REGISTRY: 12312432424234.dkr.ecr.eu-west-1.amazonaws.com | ||
− | #ECS_SERVICE: MY_ECS_SERVICE | + | #ECS_SERVICE: MY_ECS_SERVICE |
− | #ECS_CLUSTER: MY_ECS_CLUSTER | + | #ECS_CLUSTER: MY_ECS_CLUSTER |
− | #ECS_TASK_DEFINITION: MY_ECS_TASK_DEFINITION | + | #ECS_TASK_DEFINITION: MY_ECS_TASK_DEFINITION |
− | + | CONTAINER_NAME: your-container-name | |
− | CONTAINER_NAME: your-container-name | + | |
− | |||
jobs: | jobs: |
Revision as of 22:55, 14 May 2023
name: Build & deploy xxxxx container to stage env on: workflow_dispatch env: ACTIONS_RUNNER_DEBUG: true #AWS_REGION: MY_AWS_REGION ECR_REPOSITORY: your-repo ECR_REGISTRY: 12312432424234.dkr.ecr.eu-west-1.amazonaws.com #ECS_SERVICE: MY_ECS_SERVICE #ECS_CLUSTER: MY_ECS_CLUSTER #ECS_TASK_DEFINITION: MY_ECS_TASK_DEFINITION CONTAINER_NAME: your-container-name
jobs: build-docker-image: runs-on: self-hosted environment: build permissions: id-token: write contents: read steps: - name: Checkout uses: actions/checkout@v3
- name: Configure AWS Credentials uses: actions/configure-aws-credentials@v2.0.0 with: aws-region: eu-west-1
- name: Login to Private ECR id: login-private-ecr uses: actions/amazon-ecr-login@v2.0.0 - name: Build, tag, and push image to Amazon ECR id: build-image env: #ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} #IMAGE_TAG: ${{ github.sha }} IMAGE_TAG: latest working-directory: ./your-working-dir run: | # Build a docker container and # push it to ECR so that it can # be deployed to ECS.
echo "DEBUG: $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . echo "============ BEGIN DEBUG ================" aws ecr describe-repositories | grep repositoryName echo "============ END DEBUG ================" docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT deploy-docker-image: runs-on: self-hosted environment: deploy needs: build-docker-image permissions: id-token: write contents: read
steps: - name: Checkout uses: actions/checkout@v3
- name: Configure AWS Credentials uses: actions/[email protected] with: aws-region: eu-west-1
- name: Login to Private ECR id: login-private-ecr uses: actions/[email protected] - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 with: aws-access-key-id: ${{ secrets.STAGING_DEPLOY_ACCESS_KEY }} aws-secret-access-key: ${{ secrets.STAGING_DEPLOY_ACCESS_SECRET }} aws-region: eu-west-1
- name: Force ECS deployment run: | aws ecs update-service --cluster your-cluster-name --service your-service --force-new-deployment
Advertising: