Created
December 13, 2024 20:10
-
-
Save cdbkr/cb52173d4a842e147742a91d416f3da4 to your computer and use it in GitHub Desktop.
.github/workflows/ci.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build artifacts and deploy to the Infrastructure Repo Stack | |
on: | |
push: | |
branches: [main] | |
jobs: | |
build: | |
name: Build Image | |
runs-on: ubuntu-latest | |
outputs: | |
built-image-version: ${{ steps.git-tag.outputs.new_tag }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} | |
aws-default-region: eu-central-1 | |
aws-region: eu-central-1 | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Bump version and push tag | |
id: git-tag | |
uses: anothrNick/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB_ACTIONS }} | |
WITH_V: false | |
INITIAL_VERSION: 1.1.0 | |
DEFAULT_BUMP: patch | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Build, tag, and push image to Amazon ECR | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: my-organization/simple-api | |
IMAGE_TAG: ${{ steps.git-tag.outputs.new_tag }} | |
run: | | |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
deploy: | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout prod repo | |
uses: actions/checkout@v2 | |
with: | |
repository: my-organization/prod-env | |
token: ${{ secrets.TOKEN_GITHUB_ACTIONS }} | |
- name: Promote Prod env version | |
uses: ./actions/kustomize-edit-env-image/ | |
id: kustomize-edit-prod-image | |
with: | |
path: './apps/simple-api/prod/' | |
new-image-service: 'simple-api' | |
new-image-name: ${{ steps.login-ecr.outputs.registry }}/my-organization/simple-api | |
new-image-version: ${{ needs.build.outputs.built-image-version }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment