Skip to content

Merge pull request #8 from sktston/feature/update-1.1.0 #8

Merge pull request #8 from sktston/feature/update-1.1.0

Merge pull request #8 from sktston/feature/update-1.1.0 #8

name: Python CI with Docker (AWS)
on:
push:
branches:
- develop
workflow_dispatch:
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_MWP }}
# ECR_REGISTRY: 207912665906.dkr.ecr.ap-northeast-2.amazonaws.com
ECR_REGISTRY: 931639357206.dkr.ecr.ap-northeast-2.amazonaws.com
ECR_REPOSITORY: mwp/tails
IMAGE_TAG: ${{ github.sha }}
DOCKERFILE_PATH: docker/Dockerfile.tails-server
jobs:
build-and-push-image:
runs-on: ubuntu-20.04
steps:
- name: Slack message - start
uses: act10ns/[email protected]
with:
status: starting
if: always()
- name: Checkout tails-server
uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
id: build-and-push-to-ecr
run: |
docker build -f $DOCKERFILE_PATH -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: Slack messsae - end
uses: act10ns/[email protected]
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
if: always()
update-configuration:
needs: build-and-push-image
runs-on: ubuntu-20.04
concurrency: kustomize
steps:
- name: Checkout mwp-config
uses: actions/checkout@v2
with:
repository: sktston/mwp-config
token: ${{ secrets.PAT }}
- name: Setup Kustomize
id: setup-kustomize
uses: imranismail/setup-kustomize@v1
with:
kustomize-version: "3.9.4"
- name: Update the image tag with Kustomize
id: update-config-with-kustomize
run: |
git config user.name github-actions
git config user.email [email protected]
git checkout ${GITHUB_REF##*/}
git pull origin ${GITHUB_REF##*/}
cd overlays/${GITHUB_REF##*/}
kustomize edit set image $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
git add kustomization.yaml
git commit -m "Deploying image $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
git push origin ${GITHUB_REF##*/}
- name: Slack messsae - end
uses: act10ns/[email protected]
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
if: always()