Release 3.5.0 #8
Workflow file for this run
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: Deploy on Release | |
on: | |
release: | |
types: [published] | |
jobs: | |
ci: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
node: ['20.10.0'] | |
steps: | |
- name: Checkout π | |
uses: actions/checkout@v3 | |
- name: Setup node env π | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node }} | |
cache: yarn | |
- name: Install dependencies π¨π»βπ» | |
run: yarn install --frozen-lockfile --prefer-offline | |
- name: Run linter π | |
run: yarn lint | |
- name: Run tests π§ͺ | |
run: yarn test | |
build: | |
needs: ci | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Prepare | |
id: prep | |
run: | | |
DOCKER_IMAGE=12cactus/espi | |
VERSION=edge | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
VERSION=${GITHUB_REF#refs/tags/} | |
elif [[ $GITHUB_REF == refs/heads/* ]]; then | |
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') | |
elif [[ $GITHUB_REF == refs/pull/* ]]; then | |
VERSION=pr-${{ github.event.number }} | |
fi | |
TAGS="${DOCKER_IMAGE}:${VERSION}" | |
if [ "${{ github.event_name }}" = "push" ]; then | |
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}" | |
fi | |
echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
echo "tags=${TAGS}" >> $GITHUB_OUTPUT | |
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Build and push version | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.prep.outputs.tags }} | |
labels: | | |
org.opencontainers.image.source=${{ github.event.repository.html_url }} | |
org.opencontainers.image.created=${{ steps.prep.outputs.created }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
- name: Build and push latest | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
tags: 12cactus/espi:latest | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Make Deploy | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.DEPLOY_HOST }} | |
username: ${{ secrets.DEPLOY_USERNAME }} | |
key: ${{ secrets.DEPLOY_KEY }} | |
passphrase: ${{ secrets.DEPLOY_PASSPHRASE }} | |
port: ${{ secrets.DEPLOY_PORT }} | |
script: ${{ secrets.DEPLOY_SCRIPT }} |