This repository has been archived by the owner on May 21, 2024. It is now read-only.
Merge pull request #19 from photonsquid/BSoDium-patch-1 #78
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: | |
push: | |
branches: | |
- main # Push to main branch | |
- ci-cd/* | |
jobs: | |
test: | |
runs-on: "ubuntu-latest" | |
steps: | |
- uses: actions/checkout@v1 | |
- name: "Set up node" | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 17.x | |
- name: "Run tests" | |
run: | | |
rm -rf node_modules && yarn install --frozen-lockfile | |
yarn run build --if-present | |
yarn test | |
publish: | |
runs-on: "ubuntu-latest" | |
needs: test | |
if: "contains(github.event.head_commit.message, 'trigger-cd') || contains(github.event.head_commit.message, 'Merge & deploy')" | |
steps: | |
- uses: actions/checkout@v1 | |
- name: "Set up node" | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 17.x | |
- uses: actions/cache@v1 | |
id: npm-cache | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json')}} | |
restore-keys: | | |
${{ runner.os }}-npm- | |
- name: Install dependencies from cache | |
run: | | |
yarn install --prefer-offline | |
- name: Install dependencies from repository | |
run: | | |
yarn install | |
- name: Generate production build | |
run: | | |
yarn build | |
- name: Build images | |
run: | | |
docker build -t ghcr.io/photonsquid/houseportal . | |
- name: Login to GitHub Packages | |
env: | |
TOKEN: ${{ secrets.ACCESS_TOKEN }} | |
run: | | |
echo ${{ env.TOKEN }} | docker login ghcr.io -u photonsquid --password-stdin | |
- name: Push to GitHub Packages | |
id: push-to-gh-packages | |
run: | | |
tag=$(git rev-parse --short HEAD) | |
docker tag ghcr.io/photonsquid/houseportal ghcr.io/photonsquid/houseportal:$tag | |
docker push ghcr.io/photonsquid/houseportal:$tag | |
docker push ghcr.io/photonsquid/houseportal | |
echo ::set-output name=tag::$tag | |
- name: Logout | |
run: | | |
docker logout | |
- name: Create commit comment | |
uses: peter-evans/commit-comment@v2 | |
with: | |
body: | | |
## Summary | |
✅ Commit successfully deployed to GitHub packages. | |
🔗 Commit reference: `${{ github.sha }}` | |
📦 Deployed image tag: `${{ steps.push-to-gh-packages.outputs.tag }}` | |
_This message was automatically generated by an action workflow._ | |