Skip to content

Commit

Permalink
ci: Improve build pipeline (#5)
Browse files Browse the repository at this point in the history
* ci: Add hadolint

* ci: Add hadolint

* ci: Add hadolint

* ci: Add hadolint

* ci: Add hadolint

* ci: Add hadolint

* ci: Add hadolint

* docs: Modify documentation

* docs: Modify documentation

* docs: Modify documentation

* ci: Rename version.env to version

* ci: Check if aws cli works on ARM

* ci: Check if aws cli works on ARM

* ci: test build-args

* ci: Refactor Dockerfile

* ci: Refactor Dockerfile

* ci: Refactor Dockerfile

* ci: Refactor Dockerfile

* ci: Refactor Dockerfile

* ci: Refactor Dockerfile

* ci: Refactor Dockerfile

* ci: Refactor Dockerfile

* ci: Refactor Dockerfile

* ci: Refactor Dockerfile

* ci: Refactor Dockerfile

* ci: Remove unnecessary env variable
  • Loading branch information
Balsir authored Nov 22, 2023
1 parent 575eee2 commit ef47f16
Show file tree
Hide file tree
Showing 11 changed files with 476 additions and 44 deletions.
133 changes: 133 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@

# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual
identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall
community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or advances of
any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address,
without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[email protected].
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of
actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or permanent
ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the
community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.1, available at
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].

Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].

For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
[https://www.contributor-covenant.org/translations][translations].

[homepage]: https://www.contributor-covenant.org
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations
29 changes: 29 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Contributing

When contributing to this repository, please first create an issue and link the PR with it.

Please note we have a code of conduct, please follow it in all your interactions with the project.

## Pull Request Process

1. Modify `Dockerfile` or `version`. `version` contains the base Atlantis version.
2. Create PR, which trigger the docker-pr.yaml workflow.
3. After approvals and testing, PR will be merged and built images and commit automatically tagged

## Checklists for contributions

- [ ] Add [semantics prefix](#semantic-pull-requests) to your PR or Commits.
- [ ] CI tests are passing
- [ ] README.md has been updated after any changes. The variables and outputs in the README.md has been generated.

## Semantic Pull Requests

Pull Requests or Commits must follow conventional specs below:

- `ci:` Changes to our CI configuration files and scripts (example scopes: GitHub Actions)
- `docs:` Documentation only changes
- `feat:` A new feature
- `fix:` A bug fix
- `refactor:` A code change that neither fixes a bug nor adds a feature
- `style:` Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
- `test:` Adding missing tests or correcting existing tests
21 changes: 21 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Description

<!--
Please include a summary of the change, provide a justification and which issue is fixed.
-->

## Type of change

- [ ] A bug fix (PR prefix `fix`)
- [ ] A new feature (PR prefix `feat`)
- [ ] A code change that neither fixes a bug nor adds a feature (PR prefix `refactor`)
- [ ] Adding missing tests or correcting existing tests (PR prefix `test`)
- [ ] Changes that do not affect the meaning of the code like white-spaces, formatting, missing semi-colons, etc. (PR prefix `style`)
- [ ] Changes to our CI configuration files and scripts (PR prefix `ci`)
- [ ] Documentation only changes (PR prefix `docs`)

## How Has This Been Tested?

<!--
Please describe the tests that you ran to verify your changes.
-->
19 changes: 10 additions & 9 deletions .github/workflows/docker-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ on:
- 'main'
paths:
- 'Dockerfile*'
- 'version.env'
- '.github/workflows/**'

env:
DOCKERFILE_TAG: ${{ github.event.pull_request.head.sha }}
DOCKERFILE: Dockerfile-debian
- 'version'

jobs:
build-image:
Expand All @@ -25,12 +20,18 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Lint Dockerfile
id: hadolint
uses: hadolint/[email protected]
with:
dockerfile: "./Dockerfile-${{ matrix.os }}"
failure-threshold: warning

- name: Get Atlantis version
id: atlantis-version
shell: bash
run: |
source ./version.env
echo "ATLANTIS_VERSION=$ATLANTIS_VERSION" >> "$GITHUB_OUTPUT"
echo "ATLANTIS_VERSION=$(cat version)" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand Down Expand Up @@ -67,4 +68,4 @@ jobs:
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
push: true
26 changes: 14 additions & 12 deletions .github/workflows/docker-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ on:
- 'main'
paths:
- 'Dockerfile*'
- 'version.env'
- '.github/workflows/**'
- 'version'

jobs:
tag:
Expand All @@ -24,33 +23,37 @@ jobs:
id: atlantis-version
shell: bash
run: |
source ./version.env
echo "ATLANTIS_VERSION=$ATLANTIS_VERSION" >> "$GITHUB_OUTPUT"
echo "ATLANTIS_VERSION=$(cat version)" >> "$GITHUB_OUTPUT"
- name: Construct tag
id: tag
shell: bash
run: |
latest_version_tag=$(git describe --tags --match="${{ steps.atlantis-version.outputs.ATLANTIS_VERSION }}-v*" --abbrev=0 --always HEAD)
if [[ $latest_version_tag =~ ^${{ steps.atlantis-version.outputs.ATLANTIS_VERSION }}-v* ]]; then
if [[ $latest_version_tag =~ ^${{ steps.atlantis-version.outputs.ATLANTIS_VERSION }}-v* ]]; then
echo "A tag $latest_version_tag exists for this Atlantis version. Incrementing..."
old_suffix=$(echo $latest_version_tag | sed "s/${{ steps.atlantis-version.outputs.ATLANTIS_VERSION }}-v//g")
new_suffix=$(($old_suffix+1))
tag="${{ steps.atlantis-version.outputs.ATLANTIS_VERSION }}-v$new_suffix"
else
else
echo "No tag exists for this Atlantis version. Creating new v1 tag..."
tag="${{ steps.atlantis-version.outputs.ATLANTIS_VERSION }}-v1"
fi
echo "New tag: $tag"
echo "New tag: $tag"
echo "TAG=$tag" >> "$GITHUB_OUTPUT"
- name: Create push tag
- name: Push tag
run: |
git tag ${{ steps.tag.outputs.TAG }}
git push origin ${{ steps.tag.outputs.TAG }}
- name: Create GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release create ${{ steps.tag.outputs.TAG }} --generate-notes --draft

build-image:
needs: tag
runs-on: ubuntu-22.04
Expand All @@ -67,8 +70,7 @@ jobs:
id: atlantis-version
shell: bash
run: |
source ./version.env
echo "ATLANTIS_VERSION=$ATLANTIS_VERSION" >> "$GITHUB_OUTPUT"
echo "ATLANTIS_VERSION=$(cat version)" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand Down
2 changes: 0 additions & 2 deletions Dockerfile-alpine
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,3 @@ COPY --from=builder /aws-cli-bin/ /usr/local/bin/
# Install Infracost
ARG INFRACOST_VERSION=v0.10.22
RUN curl -fsSL https://raw.githubusercontent.com/infracost/infracost/$INFRACOST_VERSION/scripts/install.sh | sh


24 changes: 13 additions & 11 deletions Dockerfile-debian
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
ARG ATLANTIS_VERSION

FROM ghcr.io/runatlantis/atlantis:${ATLANTIS_VERSION}-debian
ARG AWS_CLI_VERSION=2.11.19
ARG INFRACOST_VERSION=v0.10.22

# Install AWS CLI
RUN apt install unzip
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-$AWS_CLI_VERSION.zip" -o "awscliv2.zip"
RUN unzip awscliv2.zip
RUN ./aws/install
# Download AWS CLI
FROM curlimages/curl:8.1.1 as awscli
ARG AWSCLI_VERSION=2.11.19
RUN curl -sSL "https://awscli.amazonaws.com/awscli-exe-linux-$(arch)-${AWSCLI_VERSION}.zip" -o "/tmp/awscli.zip" && \
unzip /tmp/awscli.zip -d /tmp

RUN rm awscliv2.zip
RUN rm -rf ./aws
FROM ghcr.io/runatlantis/atlantis:${ATLANTIS_VERSION}-debian
COPY --from=awscli /tmp/aws /tmp/aws
RUN /tmp/aws/install \
&& rm -rf /tmp/aws \
&& aws --version

# Install Infracost
ARG INFRACOST_VERSION=v0.10.22
# hadolint ignore=DL4006
RUN curl -fsSL https://raw.githubusercontent.com/infracost/infracost/$INFRACOST_VERSION/scripts/install.sh | sh
RUN infracost --version
Loading

0 comments on commit ef47f16

Please sign in to comment.