Skip to content

Various tweaks #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
- name: Build docker container
run: docker build -t docker.pkg.github.com/bahlo/discord-retention-bot/discord-retention-bot:branch .
run: docker build -t ghcr.io/${GITHUB_REPOSITORY}/discord-retention-bot:branch .
build_publish:
name: Build and publish docker container
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags') # Run only on main or tags
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/container' || startsWith(github.ref, 'refs/tags') # Run only on main or tags
needs:
- clippy_check
- test
Expand All @@ -101,19 +101,24 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Login
run: docker login docker.pkg.github.com -u bahlo -p "${{ secrets.GITHUB_TOKEN }}"
- name: Login to GitHub Container Registry
run: docker login ghcr.io -u ${GITHUB_ACTOR} -p "${{ secrets.GITHUB_TOKEN }}"
- name: Build and publish docker latest
if: github.ref == 'refs/heads/main'
run: |
docker build -t docker.pkg.github.com/bahlo/discord-retention-bot/discord-retention-bot:latest .
docker push docker.pkg.github.com/bahlo/discord-retention-bot/discord-retention-bot:latest
docker build -t ghcr.io/${GITHUB_REPOSITORY}/discord-retention-bot:latest .
docker push ghcr.io/${GITHUB_REPOSITORY}/discord-retention-bot:latest
- name: Build and publish docker testing
if: github.ref == 'refs/heads/container'
run: |
docker build -t ghcr.io/${GITHUB_REPOSITORY}/discord-retention-bot:testing .
docker push ghcr.io/${GITHUB_REPOSITORY}/discord-retention-bot:testing
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove the whole container branch logic? Does it make sense to build the container on non-main branches but only push it on main instead?

- name: Build and publish docker tag
if: startsWith(github.ref, 'refs/tags')
run: |
export TAG=$(echo "${{ github.ref }}" | sed 's/^refs\/tags\/v//g')
docker build -t docker.pkg.github.com/bahlo/discord-retention-bot/discord-retention-bot:$TAG .
docker push docker.pkg.github.com/bahlo/discord-retention-bot/discord-retention-bot:$TAG
docker build -t ghcr.io/${GITHUB_REPOSITORY}/discord-retention-bot:$TAG .
docker push ghcr.io/${GITHUB_REPOSITORY}/discord-retention-bot:$TAG
create_release_upload_assets:
name: Create release and upload assets
runs-on: ubuntu-latest
Expand Down Expand Up @@ -147,7 +152,7 @@ jobs:
release_name: ${{ github.ref }}
draft: false
prerelease: false
body: See [CHANGELOG.md](https://github.com/bahlo/discord-retention-bot/blob/main/CHANGELOG.md)
body: See [CHANGELOG.md](https://github.com/${GITHUB_REPOSITORY}/blob/main/CHANGELOG.md)
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
Expand Down Expand Up @@ -182,4 +187,4 @@ jobs:
- name: Run cargo publish
uses: actions-rs/cargo@v1
with:
command: publish
command: publish
Loading