Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CD with github actions #704

Merged
merged 8 commits into from
Jul 2, 2024
Merged

Add CD with github actions #704

merged 8 commits into from
Jul 2, 2024

Conversation

brunoparma88
Copy link
Contributor

Board:


Description:

Why:

To streamline app deployment, enhancing team efficiency. Utilizing GitHub Actions centralizes processes, aiding devs familiar with the repo.

Documentation:

GitHub CD Documentation

.github/workflows/cd.yml Outdated Show resolved Hide resolved
Comment on lines 3 to 6
on:
push:
branches:
- main
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe if we comment this part the job doesn't run by default (what we want) and in the docs we can clarify that they need to uncomment it if they are willing to deploy to AWS?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to what we did here:

on:
workflow_dispatch:
# This workflow should be scheduled at certain intervals
# schedule:
# - cron: '0 0 1 */3 *'
# The above cron would schedule it every 3 months. Replace with the wanted periodicity.

And we can even add worfklow_dispatch so that it can be manually triggered

.github/workflows/cd.yml Outdated Show resolved Hide resolved
docs/cd_with_aws.md Outdated Show resolved Hide resolved
@brunoparma88 brunoparma88 had a problem deploying to Add_CD_with_github_actions May 28, 2024 12:03 — with GitHub Actions Failure
Copy link
Member

@santib santib left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! LGTM 🤩

Comment on lines 3 to 7
# on:
# push:
# Uncomment and add the necessary branches to enable automatic deployment on AWS
# branches:
# - main
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only doubt I have is if having the on section completely commented might make the GHA invalid
image

Other option would be doing the same as here

on:
  workflow_dispatch:
  # Uncomment and add the necessary branches to enable automatic deployment on AWS
  # push:
    # branches:
      # - main

Comment on lines 13 to 14
environment:
name: ${{ github.ref_name }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, this requires us to create a Github environment and a branch with the exact same name. If we are forcing any naming convention, we should add it to the docs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also wondering if we should keep track of all the releases using the "Github releases" feature, and I think that relies on tagging instead of branch pushes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using "GitHub releases" based on tagging could be an interesting idea to track all releases. It offers a structured approach with release notes and contributors. However, it requires a different setup from the process investigated in this PR. Let's consider exploring this in a separate card and PR for future enhancements.

id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, tag, and push image to Amazon ECR
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why we do this manually instead of using docker/build-push-action? I think you can get the imageID as well using it

The GitHub Actions workflow will automatically deploy to the correct environment based on the branch being pushed to. The branch `main` will always be linked to the `production` environment, while other branches will use their own names as the environment. All environments added in GitHub must have the same name as the branches.

5. **GitHub Repository Setup**:
- Secrets: Add the following secrets to your GitHub repository:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These secrets are environment specific right? Maybe we should clarify that these are not repo level settings, but environment level

@JulianPasquale JulianPasquale requested a review from a team June 11, 2024 19:52
Comment on lines 41 to 45
on:
push:
branches:
- main
- dev
Copy link
Member

@santib santib Jun 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on:
  push:
    branches:
      - main
      - dev

you can use a yaml block code here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise it looks like this:
image

Copy link
Contributor

@lauperalti lauperalti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 Looks Great!


4. **Create Environments**:

The GitHub Actions workflow will automatically deploy to the correct environment based on the branch being pushed to. The branch `main` will always be linked to the `production` environment, while other branches will use their own names as the environment. All environments added in GitHub must have the same name as the branches.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammarly suggestion

Suggested change
The GitHub Actions workflow will automatically deploy to the correct environment based on the branch being pushed to. The branch `main` will always be linked to the `production` environment, while other branches will use their own names as the environment. All environments added in GitHub must have the same name as the branches.
The GitHub Actions workflow will automatically deploy to the correct environment based on the branch being pushed to. The branch `main` will always be linked to the `production` environment, while other branches will use their names as the environment. All environments added in GitHub must have the same name as the branches.

- `ECS_CLUSTER`: The name of your ECS cluster.

6. **GitHub Actions Workflow**:
To set up the GitHub Actions workflow for continuous deployment to AWS, you need to modify the existing cd.yml file in the .github/workflows directory of your GitHub repository.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammarly suggestion

Suggested change
To set up the GitHub Actions workflow for continuous deployment to AWS, you need to modify the existing cd.yml file in the .github/workflows directory of your GitHub repository.
To set up the GitHub Actions workflow for continuous deployment to AWS, you need to modify the existing cd.yml file in your GitHub repository's `.github/workflows` directory.

@brunoparma88 brunoparma88 merged commit a3a9765 into main Jul 2, 2024
6 checks passed
@brunoparma88 brunoparma88 deleted the Add_CD_with_github_actions branch July 2, 2024 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants