Home

Github Actions

Github provides a genorous CI/CD platform called Github Actions or Github Workflow. In it, you can run any for predefined events! For this week, i ran 2 "jobs":

Apart from the official docs, i used this website for guide: https://brendanforster.com/notes/building-a-github-action-to-make-myself-redundant/

Action to test PR

I decided to use golang for the repo. When there's a PR, it builds it and checks it. Since the build results are shown in the PR page, it's easy to find if there's something wrong with it.

name: Go

on:
  pull_request:
    branches: [ "master" ]

jobs:

  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4

    - name: Set up Go
      uses: actions/setup-go@v4
      with:
        go-version: '1.20'

    - name: Build
      run: go build -v ./...

    - name: Test
      run: go test -v ./...

Pushing build artifacts to S3

using the aws-actions/configure-aws-credentials, i setup the aws access keys. Then, using the aws-cli, i copied the built artifacts to s3:

name: Go

on:
  push:
    branches: [ "master" ]

jobs:

  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4

    - name: Set up Go
      uses: actions/setup-go@v4
      with:
        go-version: '1.20'

    - name: Build
      run: go build -v ./...

    - name: Test
      run: go test -v ./...

    - name: Configure AWS Credentials
      uses: aws-actions/configure-aws-credentials@v4.1.0
      with:
        aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
        aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        aws-region: ${{ secrets.AWS_DEFAULT_REGION }}

    - name: sync build artifacts
      run: aws s3 cp gh-actions "s3://$AWS_S3_BUCKET/artifacts/"
      env:
        AWS_S3_BUCKET: ${{ vars.AWS_S3_BUCKET }}