➖ intents: remove members #266
This file contains hidden or 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: [main] | |
| workflow_dispatch: | |
| jobs: | |
| version_check: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_update: ${{ steps.outputs.outputs.should_update }} | |
| version: ${{ steps.outputs.outputs.version }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get version | |
| id: get_version | |
| run: | | |
| echo "version=$(grep -oP '(?<=version: ")[^"]*' config.yml)" >> $GITHUB_OUTPUT | |
| - name: Get latest version tag | |
| id: get_latest_tag | |
| uses: WyriHaximus/github-action-get-previous-tag@v1 | |
| with: | |
| prefix: v | |
| fallback: 0.0.0 | |
| - name: Compare versions | |
| id: compare_versions | |
| run: | | |
| echo "should_update=$(python3 -c "from packaging import version; print(version.parse('${{ steps.get_version.outputs.version }}') > version.parse('${{ steps.get_latest_tag.outputs.tag }}'))")" >> $GITHUB_OUTPUT | |
| - name: Set outputs | |
| id: outputs | |
| if: steps.compare_versions.outputs.should_update == 'True' | |
| run: | | |
| echo "should_update=True" >> $GITHUB_OUTPUT | |
| echo "version=${{ steps.get_version.outputs.version }}" >> $GITHUB_OUTPUT | |
| create_release: | |
| needs: version_check | |
| if: needs.version_check.outputs.should_update == 'True' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: Get Changelog | |
| id: get_changelog | |
| run: | | |
| { | |
| echo 'changelog<<EOF' | |
| git log -1 --pretty=format:"%b" | |
| echo "" | |
| echo 'EOF' | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Create release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ needs.version_check.outputs.version }} | |
| body: ${{ steps.get_changelog.outputs.changelog }} | |
| - name: Send changelog to Discord | |
| uses: tsickert/discord-webhook@v5.3.0 | |
| with: | |
| webhook-url: ${{ secrets.WEBHOOK_URL }} | |
| content: | | |
| # Version ${{ needs.version_check.outputs.version }} | |
| <@&${{ secrets.WEBHOOK_ROLE }}> | |
| ${{ steps.get_changelog.outputs.changelog }} | |
| publish_images: | |
| needs: [version_check, create_release] | |
| if: needs.version_check.outputs.should_update == 'True' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Extract Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.repository }} | |
| ghcr.io/${{ github.repository }} | |
| tags: | | |
| type=raw,value=latest | |
| type=semver,pattern={{version}},value=v${{ needs.version_check.outputs.version }} | |
| type=semver,pattern={{version}},value=${{ needs.version_check.outputs.version }} | |
| type=semver,pattern={{major}}.{{minor}},value=v${{ needs.version_check.outputs.version }} | |
| type=semver,pattern={{major}}.{{minor}},value=${{ needs.version_check.outputs.version }} | |
| type=semver,pattern={{major}},value=v${{ needs.version_check.outputs.version }} | |
| type=semver,pattern={{major}},value=${{ needs.version_check.outputs.version }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| platforms: linux/amd64,linux/arm64,linux/arm/v7 | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| deployment: | |
| needs: [version_check, create_release] | |
| if: needs.version_check.outputs.should_update == 'True' | |
| runs-on: self-hosted | |
| steps: | |
| - name: Set up context | |
| run: | | |
| cd ${{ secrets.DIRECTORY }} | |
| source venv/bin/activate | |
| - name: Dump database | |
| run: | | |
| file_name="fixtweet_$(date +%d%m%Y_%H%M%S).sql" | |
| mkdir -p database/backups | |
| mysqldump -u ${{ secrets.DB_USER }} -p${{ secrets.DB_PASSWORD }} --databases ${{ secrets.DB_NAME }} > database/backups/$file_name | |
| - name: Stop | |
| run: | | |
| pm2 stop ${{ secrets.PM2_PROCESS_NAME }} | |
| - name: Reset local environment | |
| run: | | |
| rm -f log.txt | |
| git reset --hard | |
| git clean -fd | |
| - name: Checkout | |
| run: | | |
| git fetch --all --tags | |
| git checkout refs/tags/v${{ needs.version_check.outputs.version }} | |
| - name: Install dependencies | |
| run: | | |
| pip install --force-reinstall -r requirements.txt | |
| - name: Migrate database | |
| run: | | |
| masonite-orm migrate -C database/config.py -d database/migrations | |
| - name: Start | |
| run: | | |
| pm2 start ${{ secrets.PM2_PROCESS_NAME }} |