Skip to content

お知らせの更新 (#241) #71

お知らせの更新 (#241)

お知らせの更新 (#241) #71

Workflow file for this run

name: Build
on:
push:
branches: [ main, develop ]
env:
DOCKER_REGISTRY: boarmap-dev.gifu-nct.ac.jp:5000
DOCKER_REPOSITORY: boar-map
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Update history.md
shell: bash
if: ${{ contains(github.event.head_commit.message, '[meta]') }}
run: |
cd .github/scripts/
php history.php '${{ github.event.head_commit.message }}'
LATEST_V=`php latest.php`
echo "LATEST_V=$LATEST_V" >> $GITHUB_ENV
- name: Commit changes
if: ${{ contains(github.event.head_commit.message, '[meta]') }}
run: |
git remote set-url origin https://github-actions:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add .
git commit -m ":robot: 更新履歴の追加 (Version ${{ env.LATEST_V }})";
git push origin HEAD:${GITHUB_REF} -f;
- name: Setup Build Cache
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-${{ hashFiles('./yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ hashFiles('./yarn.lock') }}
${{ runner.os }}-
refs/head/main
# ref. https://qiita.com/iery/items/43b72813c394050b8bbc
- name: Extract branch name
shell: bash
run: echo "::set-output name=branch::${GITHUB_REF#refs/heads/}"
id: extract_branch
- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Create Tag
env:
BRANCH_NAME: ${{ steps.extract_branch.outputs.branch }}
run: |
TAG=${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_REPOSITORY }}:$BRANCH_NAME
if [ "$BRANCH_NAME" == "main" ]; then
LATEST=${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_REPOSITORY }}:latest
echo "TAGS=$TAG,$LATEST" >> $GITHUB_ENV
echo latest
else
echo "TAGS=$TAG" >> $GITHUB_ENV
fi
echo TAG $TAG
- name: Create Sentry Release
shell: bash
id: sentry_release
run: |
echo "::set-output name=env::${GITHUB_REF#refs/heads/}"
echo "::set-output name=release::$(git show --format="%H" --no-patch)"
- name: Login to Private Registry
uses: docker/login-action@v1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build image
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
build-args: |
"SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}"
"NEXT_PUBLIC_SENTRY_ENVIRONMENT=${{ steps.sentry_release.outputs.env }}"
"NEXT_PUBLIC_SENTRY_RELEASE=${{ steps.sentry_release.outputs.release }}"
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ env.TAGS }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache