Merge branch 'master' into develop #35
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: Release | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
verify-version: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.get_version.outputs.VERSION }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Get the version | |
id: get_version | |
run: "echo ::set-output name=VERSION::$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]')" | |
- name: Test snapshot | |
run: if [[ "${{ steps.get_version.outputs.VERSION }}" == *"-SNAPSHOT" ]]; then exit 1; else exit 0; fi | |
- name: Get release | |
id: get_release | |
run: echo ::set-output name=RELEASE_HTTP_CODE::$(curl -s -o out.html -w '%{http_code}' https://github.com/les-projets-cagnottes/slack-events-catcher/releases/tag/${{ steps.get_version.outputs.VERSION }};) | |
- name: Test release existence | |
run: if [[ "${{ steps.get_release.outputs.RELEASE_HTTP_CODE }}" -eq "200" ]]; then exit 1; else exit 0; fi | |
build: | |
needs: verify-version | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js 18.x | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 18.x | |
- run: npm ci | |
- run: npm run build --if-present | |
release: | |
needs: [verify-version, build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Config Git | |
run: git config user.email "${{ secrets.GIT_CONFIG_EMAIL }}" && git config user.name "${{ secrets.GIT_CONFIG_NAME }}" | |
- run: git tag ${{ needs.verify-version.outputs.version }} | |
- run: git push origin ${{ needs.verify-version.outputs.version }} | |
- name: Create Release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ needs.verify-version.outputs.version }} | |
release_name: ${{ needs.verify-version.outputs.version }} | |
body: | | |
Release ${{ needs.verify-version.outputs.version }} | |
draft: false | |
prerelease: false | |
publish-docker: | |
needs: [verify-version, build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Build the Docker image | |
run: docker build . --file Dockerfile --tag slack-events-catcher:latest | |
- name: Tag the version image for GitHub Registry | |
run: docker tag slack-events-catcher:latest docker.pkg.github.com/les-projets-cagnottes/slack-events-catcher/slack-events-catcher:${{ needs.verify-version.outputs.version }} | |
- name: Tag the latest image for GitHub Registry | |
run: docker tag slack-events-catcher:latest docker.pkg.github.com/les-projets-cagnottes/slack-events-catcher/slack-events-catcher:latest | |
- name: Login to Registry | |
run: docker login docker.pkg.github.com -u thomah -p ${{secrets.GITHUB_TOKEN}} | |
- name: Publish version to Registry | |
run: docker push docker.pkg.github.com/les-projets-cagnottes/slack-events-catcher/slack-events-catcher:${{ needs.verify-version.outputs.version }} | |
- name: Publish latest to Registry | |
run: docker push docker.pkg.github.com/les-projets-cagnottes/slack-events-catcher/slack-events-catcher:latest | |
- name: Tag the version image for Docker Hub | |
run: docker tag slack-events-catcher:latest lesprojetscagnottes/slack-events-catcher:${{ needs.verify-version.outputs.version }} | |
- name: Tag the latest image for Docker Hub | |
run: docker tag slack-events-catcher:latest lesprojetscagnottes/slack-events-catcher:latest | |
- name: Login to Docker Hub | |
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
- name: Publish version to Docker Hub | |
run: docker push lesprojetscagnottes/slack-events-catcher:${{ needs.verify-version.outputs.version }} | |
- name: Publish latest to Docker Hub | |
run: docker push lesprojetscagnottes/slack-events-catcher:latest |