Skip to content

Commit

Permalink
Rename-release (#22364)
Browse files Browse the repository at this point in the history
* Add on pull request

* Remove pull request trigger

* Release workflow ready to trigger deploy-amo

* Run release in ci to ensure tests are run and reuse the existing build job

* Add release workflow to decouple ci from cd and to wait for entire workflow to finish before triggering deployment
  • Loading branch information
KevinMind authored Jun 14, 2024
1 parent 9f8766a commit 21a6321
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
31 changes: 17 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
name: CI

on:
# Runs when there is a push to the default branch
# This triggers tests and a pushed "latest" image
# That is deployed to the "dev" environment
push:
branches:
- master
# Runs on pull requests to verify changes and push
# PR image for local testing
pull_request:
branches:
- master
# Manually dispatch to update cache or to push an image
# From any ref
workflow_dispatch:
inputs:
splits:
description: 'The number of splits for test_main'
required: true
default: '14'
# Runs when a release is published
# Pushes a tagged image
# That is deployed to the "staging/production" environments
release:
types: [published]

concurrency:
# different events on the same ref can run in parallel
Expand Down Expand Up @@ -40,7 +50,6 @@ jobs:
is_fork: ${{ steps.context.outputs.is_fork }}
is_dependabot: ${{ steps.context.outputs.is_dependabot }}
is_default_branch: ${{ steps.context.outputs.is_default_branch }}
is_push: ${{ steps.context.outputs.is_push }}

steps:
- name: Log context
Expand All @@ -63,24 +72,19 @@ jobs:
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions
is_dependabot="${{ github.actor == 'dependabot[bot]' }}"
# Are we running on a push event
# Many jobs/steps only execute or change execution on push events
is_push="${{ github.event_name == 'push' }}"
if [[ "${{ github.event_name }}" == 'pull_request' ]]; then
# repository on a pull request refers to the base which is always mozilla/addons-server
is_fork=${{ github.event.pull_request.head.repo.fork }}
else
# Repository on a push refers to the head which would be the fork
# In most events, the epository refers to the head which would be the fork
# This is different in a pullrequest where we need to check the head explicitly
is_fork="${{ github.event.repository.fork }}"
fi
echo "github.event.repository.full_name ${{ github.event.repository.full_name }}"
echo "is_default_branch=$is_default_branch" >> $GITHUB_OUTPUT
echo "is_fork=$is_fork" >> $GITHUB_OUTPUT
echo "is_dependabot=$is_dependabot" >> $GITHUB_OUTPUT
echo "is_push=$is_push" >> $GITHUB_OUTPUT
echo "event_name: ${{ github.event_name }}"
cat $GITHUB_OUTPUT
Expand All @@ -101,7 +105,6 @@ jobs:
shell: bash
run: |
is_fork="${{ needs.context.outputs.is_fork == 'true' }}"
is_default_branch="${{ needs.context.outputs.is_default_branch == 'true' }}"
is_dependabot="${{ needs.context.outputs.is_dependabot == 'true' }}"
# Default behaviour is to build images for any CI.yml run
Expand All @@ -114,7 +117,7 @@ jobs:
fi
# Dependabot PRs are treated as if they are from forks (see above)
if [[ "$is_dependabot" == 'true' && "$is_default_branch" == 'false' ]]; then
if [[ "$is_dependabot" == 'true' && "${{ github.event_name }}" == 'pull_request' ]]; then
should_build="false"
fi
Expand Down Expand Up @@ -225,7 +228,7 @@ jobs:
# to the default branch
# that is not running on a fork
if: |
needs.context.outputs.is_push == 'true' &&
github.event_name == 'push' &&
needs.context.outputs.is_default_branch == 'true' &&
needs.context.outputs.is_fork == 'false'
permissions:
Expand Down Expand Up @@ -264,7 +267,7 @@ jobs:
run: make extract_locales

- name: Push Locales
if: needs.context.outputs.is_push
if: github.event_name == 'push'
shell: bash
run: |
if [[ "${{ needs.context.outputs.is_fork == 'true' }}" == 'true' ]]; then
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/cd.yml → .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
name: Release

on:
release:
workflow_dispatch:
workflow_run:
workflows: [CI]
types:
- completed

jobs:
context:
runs-on: ubuntu-latest

steps:
- name: Log (github)
shell: bash
- shell: bash
run: |
cat <<EOF
${{toJson(github)}}
EOF

0 comments on commit 21a6321

Please sign in to comment.