Merge pull request #176 from Flo0807/dependabot/docker/debian-buster-… #30
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
test: | |
name: Test app | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: erlef/setup-beam@v1 | |
with: | |
otp-version: '26.2.1' | |
elixir-version: '1.16.0' | |
- name: Install Dependencies | |
run: mix deps.get | |
- name: Check Formatting | |
run: mix format --check-formatted | |
- name: Run Tests | |
run: mix test | |
build: | |
name: Build and push image to ghcr | |
needs: test | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Log in to the container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
deploy: | |
if: github.ref == 'refs/heads/main' | |
name: Deploy app | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Trigger deployment | |
run: | | |
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -X POST ${{ secrets.WEBHOOK_URL }} \ | |
-H "Content-Type: application/json" \ | |
-H "X-Signature: ${{ secrets.WEBHOOK_SECRET }}" \ | |
-d '{}') | |
if [ "$RESPONSE" -ne "200" ] | |
then | |
echo "Deployment failed with status ${RESPONSE}" | |
exit 1 | |
fi | |