Skip to content

pb/actions

pb/actions #101

Workflow file for this run

name: CI
on:
pull_request:
push:
branches: main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: stack
uses: freckle/stack-action@v5
- uses: freckle/weeder-action@v2
with:
ghc-version: ${{ steps.stack.outputs.compiler-version }}
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: haskell-actions/hlint-setup@v2
- uses: haskell-actions/hlint-run@v2
with:
fail-on: warning
image:
runs-on: ubuntu-latest
steps:
# TODO: docker/metadata-action
- id: prep
run: |
image=restyled/agent:$(echo "${{ github.sha }}" | head -c7)
if ${{ github.ref == 'refs/heads/main' }}; then
tags=$image,restyled/agent:main
else
tags=$image
fi
{
echo "image=${image}"
echo "tags=${tags}"
} >>"$GITHUB_INPUT"
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- uses: docker/build-push-action@v5
with:
build-args: |
REVISION=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
tags: ${{ steps.prep.outputs.tags }}
outputs:
image: ${{ steps.prep.outputs.image }}
user-data:
needs: [image]
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-east-1
steps:
- uses: actions/checkout@v4
- id: artifact
run: |
agent_image=${{ needs.image.outputs.image }}
key=src/restyle-machines/user-data/${{ github.sha }}
m4 -D AGENT_IMAGE="$agent_image" < user-data.in |
aws s3 cp --acl public-read - "s3://infra.restyled.io/$key"
echo "key=$key" >>"$GITHUB_INPUT"
outputs:
key: ${{ steps.artifact.outputs.key }}
deploy:
if: ${{ github.ref == 'refs/heads/main' }}
needs: [test, image, user-data]
runs-on: ubuntu-latest
steps:
- uses: restyled-io/gitops-deploy-action@main
with:
token: ${{ secrets.GITOPS_ACCESS_TOKEN }}
parameter-name: UserDataSourceKey
parameter-value: ${{ needs.user-data.outputs.key }}
committer-name: Restyled Commits
committer-email: [email protected]
repository: restyled-io/ops
stacks: cg-app/stacks/*/*/prod/services/restyle-machines.yaml