chore: boilerplate #44
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: Pipeline | |
on: | |
push: | |
branches: [ trunk ] | |
pull_request: | |
branches: [ trunk ] | |
registry_package: | |
types: [ published, updated ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Setup builder | |
run: docker buildx create --bootstrap --use | |
- name: Build image for testing | |
run: > | |
docker buildx build --target test | |
--cache-from type=registry,ref=ghcr.io/wojciechem/legacy:latest-cache | |
--cache-to type=registry,ref=ghcr.io/wojciechem/legacy:latest-cache | |
--pull | |
--push | |
-t ghcr.io/wojciechem/legacy:latest-test | |
-t ghcr.io/wojciechem/legacy:${GITHUB_SHA}-test . | |
test: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Pull image | |
run: docker pull ghcr.io/wojciechem/legacy:${GITHUB_SHA}-test | |
- name: Smoke test | |
run: docker run --rm -i ghcr.io/wojciechem/legacy:${GITHUB_SHA}-test vendor/bin/phpunit --filter AlivenessTest | |
- name: Check layer dependency rules | |
run: docker run --rm -i ghcr.io/wojciechem/legacy:${GITHUB_SHA}-test vendor/bin/deptrac analyse | |
deployment: | |
runs-on: ubuntu-latest | |
environment: stage | |
steps: | |
- name: create context | |
env: | |
DOCKER_CONTEXT: ${{ secrets.DOCKER_CONTEXT }} | |
run: echo "${DOCKER_CONTEXT}" | base64 --decode | docker context import swarm - | |
- name: setup keys | |
env: | |
PUBKEY: ${{ secrets.DEPLOYMENT_PUB_KEY }} | |
KEY: ${{ secrets.DEPLOYMENT_SECRET_KEY }} | |
run: mkdir -p ~/.ssh && echo "${PUBKEY}" >> ~/.ssh/id_ed25519.pub && echo "${KEY}" >> ~/.ssh/id_ed25519 && chmod 600 ~/.ssh/id_ed25519 | |
- name: add fingerprint | |
run: ssh-keyscan -H 49.12.190.228 >> ~/.ssh/known_hosts | |
- name: use context | |
run: docker context use swarm | |
- name: debug | |
run: docker stack ls |