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

Update to use vars #850

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/callable-build-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: "Deploy ECS"
on:
workflow_call:
inputs:
ref:
description: 'The git sha to build'
required: true
type: string
push:
description: 'To push or not to push'
required: true
type: boolean

permissions:
packages: write
contents: read
attestations: write
id-token: write

jobs:
build-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
ref: ${{ inputs.ref }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner}}/${{ github.event.repository.name }}

- name: Build and push Docker image
id: push
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./Dockerfile
push: ${{ inputs.push }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
if: ${{ inputs.push }}
with:
subject-name: ghcr.io/${{ github.repository_owner}}/${{ github.event.repository.name }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: ${{ inputs.push }}
42 changes: 42 additions & 0 deletions .github/workflows/callable-deploy-ecs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: "Deploy ECS"
on:
workflow_call:
inputs:
env:
description: Target environment of deployment. (stg, prod)
required: true
type: string
container_tag:
description: 'The container tag to deploy'
required: true
type: string

permissions:
contents: 'read'
id-token: 'write'

jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.env }}
steps:
- uses: actions/checkout@v4

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ vars.IAM_ROLE_ARN }}
aws-region: us-east-2

- name: Download task definition
run: |
aws ecs describe-task-definition --task-definition ${{ vars.ECS_TASK_DEF_FAMILY }} --query taskDefinition > task-definition.json

# TODO: Substitute in the correct tag that should be deployed next
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@df9643053eda01f169e64a0e60233aacca83799a
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ vars.ECS_SERVICE }}
cluster: ${{ vars.ECS_CLUSTER }}
wait-for-service-stability: true
19 changes: 19 additions & 0 deletions .github/workflows/callable-deploy-ghpages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: "Deploy ECS"
on:
workflow_call:

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 14.x
- run: |
npm install
npm run build
- uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: build
40 changes: 40 additions & 0 deletions .github/workflows/manual-build-and-deploy-ref.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: 'Manually deploy tag'
on:
workflow_dispatch:
inputs:
ref:
type: string
required: true
description:
env:
type: environment
default: stg

jobs:
pre-run:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

build-docker:
name: "Build Container"
uses: ./.github/workflows/callable-build-docker.yml
secrets: inherit
with:
ref: ${{ inputs.ref }}
push: true
needs:
- pre-run

deploy-ecs:
name: "Deploy container to ECS"
uses: ./.github/workflows/callable-deploy-ecs.yml
secrets: inherit
with:
env: ${{ inputs.env }}
container-tag: ${{ inputs.ref }}
needs:
- build-docker
31 changes: 31 additions & 0 deletions .github/workflows/manual-deploy-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: 'Manually deploy tag'
on:
workflow_dispatch:
inputs:
tag:
type: string
required: true
description: The tag to deploy (must already exist)
env:
type: environment
default: stg

jobs:
pre-run:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}


deploy-env-stg:
name: "Deploy to stg environment"
uses: ./.github/workflows/callable-deploy-ecs.yml
secrets: inherit
with:
env: ${{ inputs.env }}
container_tag: ${{ inputs.tag }}
needs:
- pre-run
35 changes: 35 additions & 0 deletions .github/workflows/on-merge-to-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: On merge to master
on:
push:
branches:
- master
workflow_dispatch:

jobs:
pre-run:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

build-docker:
name: "Build Container"
uses: ./.github/workflows/callable-build-docker.yml
secrets: inherit
with:
ref: ${{ github.sha }}
push: true
needs:
- pre-run

deploy-env-stg:
name: "Deploy to stg environment"
uses: ./.github/workflows/callable-deploy-ecs.yml
secrets: inherit
with:
env: stg
container_tag: ${{ github.sha }}
needs:
- build-docker
16 changes: 16 additions & 0 deletions .github/workflows/on-pr-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Pull Request Updated
on:
pull_request:
types:
- opened
- edited
- synchronize

jobs:
build-docker:
name: "Build Container"
uses: ./.github/workflows/callable-build-docker.yml
secrets: inherit
with:
ref: ${{ github.sha }}
push: false
41 changes: 41 additions & 0 deletions .github/workflows/on-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: On tag
on:
push:
tags: '*'
workflow_dispatch:

jobs:
pre-run:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

build-docker:
name: "Build Container"
uses: ./.github/workflows/callable-build-docker.yml
secrets: inherit
with:
ref: ${{ github.sha }}
push: true
needs:
- pre-run

deploy-stg:
name: "Deploy to stg environment"
uses: ./.github/workflows/callable-deploy-ecs.yml
secrets: inherit
with:
env: stg
container_tag: aoeuaoeu
needs:
- build-docker

deploy-pages:
name: "Publish gh-pages"
uses: ./.github/workflows/callable-deploy-ghpages.yml
secrets: inherit
needs:
- deploy-stg
32 changes: 0 additions & 32 deletions .github/workflows/production.yml

This file was deleted.

Loading