|
| 1 | +name: Docker CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - "main" |
| 7 | + |
| 8 | +jobs: |
| 9 | + docker: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Set up QEMU |
| 13 | + uses: docker/setup-qemu-action@v3 |
| 14 | + |
| 15 | + - name: Set up Docker Buildx |
| 16 | + uses: docker/setup-buildx-action@v3 |
| 17 | + |
| 18 | + - name: Checkout code |
| 19 | + uses: actions/checkout@v2 |
| 20 | + |
| 21 | + - name: Extract version from package.json |
| 22 | + id: extract_version |
| 23 | + run: echo "::set-output name=version::$(node -p "require('./package.json').version")" |
| 24 | + |
| 25 | + - name: Login to Docker Hub |
| 26 | + uses: docker/login-action@v3 |
| 27 | + with: |
| 28 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 29 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 30 | + |
| 31 | + - name: Build and push |
| 32 | + uses: docker/build-push-action@v6 |
| 33 | + with: |
| 34 | + push: true |
| 35 | + tags: | |
| 36 | + kweg/omnipoly:${{ steps.extract_version.outputs.version }} |
| 37 | + kweg/omnipoly:latest |
| 38 | +
|
| 39 | + - name: Extract changelog for the version |
| 40 | + id: extract_changelog |
| 41 | + run: | |
| 42 | + VERSION=${{ steps.extract_version.outputs.version }} |
| 43 | + CHANGELOG=$(grep -A 10 "### $VERSION" changelog.md | tail -n +2) |
| 44 | + echo "::set-output name=changelog::$CHANGELOG" |
| 45 | +
|
| 46 | + - name: Create GitHub Release |
| 47 | + id: create_release |
| 48 | + uses: actions/create-release@v1 |
| 49 | + env: |
| 50 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + with: |
| 52 | + tag_name: v${{ steps.extract_version.outputs.version }} |
| 53 | + release_name: Release v${{ steps.extract_version.outputs.version }} |
| 54 | + body: | |
| 55 | + ### Changelog |
| 56 | +
|
| 57 | + ${{ steps.extract_changelog.outputs.changelog }} |
| 58 | +
|
| 59 | + ### Build Results |
| 60 | + ${{ steps.build_push.outputs.digest }} |
| 61 | + draft: false |
| 62 | + prerelease: false |
| 63 | + |
| 64 | + - name: Create GitHub Tag |
| 65 | + run: | |
| 66 | + git config --global user.name 'github-actions[bot]' |
| 67 | + git config --global user.email 'github-actions[bot]@users.noreply.github.com' |
| 68 | + git tag v${{ steps.extract_version.outputs.version }} |
| 69 | + git push origin v${{ steps.extract_version.outputs.version }} |
0 commit comments