Skip to content

Commit d9504ae

Browse files
authored
Merge pull request #454 from larissalages/test/github-ecr-action
Test/GitHub ecr action
2 parents 3728408 + 485011c commit d9504ae

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# This is a basic workflow to help you get started with Actions
2+
name: Deploy to AWS ECR
3+
# Controls when the workflow will run
4+
on:
5+
# Triggers the workflow on push or pull request events but only for the master branch
6+
push:
7+
branches: [test/github-ecr-action]
8+
pull_request:
9+
branches: [test/github-ecr-action]
10+
jobs:
11+
build:
12+
name: Build Image
13+
runs-on: ubuntu-latest
14+
# Steps represent a sequence of tasks that will be executed as part of the job
15+
steps:
16+
17+
- name: Check out code
18+
uses: actions/checkout@v2
19+
- name: Configure AWS credentials
20+
uses: aws-actions/configure-aws-credentials@v1
21+
with:
22+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
23+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
24+
aws-region: ap-south-1
25+
- name: Login to Amazon ECR
26+
id: login-ecr
27+
uses: aws-actions/amazon-ecr-login@v1
28+
- name: Build, tag, and push image to Amazon ECR
29+
env:
30+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
31+
ECR_REPOSITORY: code-problems
32+
IMAGE_TAG: ${{ github.sha }}
33+
run: |
34+
# Build a docker container and push it to ECR
35+
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
36+
echo "Pushing image to ECR..."
37+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
38+
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# pull the official base image (Background o.s for container)
2+
FROM python:3.9.7
3+
4+
# image comes with gpg 2.x but we need gpg 1.x
5+
RUN apt-get update && \
6+
apt-get remove -y gnupg && \
7+
apt-get install -y gnupg1
8+

0 commit comments

Comments
 (0)